@happier-dev/stack 0.1.0-preview.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +501 -0
- package/bin/hstack.mjs +348 -0
- package/docs/codex-mcp-resume.md +129 -0
- package/docs/edison.md +74 -0
- package/docs/forking-and-branding.md +189 -0
- package/docs/happy-development.md +22 -0
- package/docs/isolated-linux-vm.md +243 -0
- package/docs/menubar.md +244 -0
- package/docs/mobile-ios.md +322 -0
- package/docs/monorepo-migration.md +20 -0
- package/docs/paths-and-env.md +154 -0
- package/docs/remote-access.md +43 -0
- package/docs/server-flavors.md +147 -0
- package/docs/stacks.md +330 -0
- package/docs/tauri.md +60 -0
- package/docs/worktrees-and-forks.md +133 -0
- package/extras/swiftbar/auth-login.sh +29 -0
- package/extras/swiftbar/git-cache-refresh.sh +122 -0
- package/extras/swiftbar/hstack-term.sh +133 -0
- package/extras/swiftbar/hstack.5s.sh +296 -0
- package/extras/swiftbar/hstack.sh +35 -0
- package/extras/swiftbar/icons/happy-green.png +0 -0
- package/extras/swiftbar/icons/happy-orange.png +0 -0
- package/extras/swiftbar/icons/happy-red.png +0 -0
- package/extras/swiftbar/icons/logo-white.png +0 -0
- package/extras/swiftbar/install.sh +265 -0
- package/extras/swiftbar/lib/git.sh +629 -0
- package/extras/swiftbar/lib/icons.sh +92 -0
- package/extras/swiftbar/lib/render.sh +999 -0
- package/extras/swiftbar/lib/system.sh +244 -0
- package/extras/swiftbar/lib/utils.sh +717 -0
- package/extras/swiftbar/set-interval.sh +65 -0
- package/extras/swiftbar/set-server-flavor.sh +61 -0
- package/extras/swiftbar/wt-pr.sh +140 -0
- package/node_modules/@happier-dev/cli-common/README.md +6 -0
- package/node_modules/@happier-dev/cli-common/dist/index.d.ts +4 -0
- package/node_modules/@happier-dev/cli-common/dist/index.d.ts.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/index.js +4 -0
- package/node_modules/@happier-dev/cli-common/dist/index.js.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/links/index.d.ts +18 -0
- package/node_modules/@happier-dev/cli-common/dist/links/index.d.ts.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/links/index.js +25 -0
- package/node_modules/@happier-dev/cli-common/dist/links/index.js.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/links.d.ts +2 -0
- package/node_modules/@happier-dev/cli-common/dist/links.d.ts.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/links.js +2 -0
- package/node_modules/@happier-dev/cli-common/dist/links.js.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/update/index.d.ts +67 -0
- package/node_modules/@happier-dev/cli-common/dist/update/index.d.ts.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/update/index.js +259 -0
- package/node_modules/@happier-dev/cli-common/dist/update/index.js.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/workspaces/index.d.ts +17 -0
- package/node_modules/@happier-dev/cli-common/dist/workspaces/index.d.ts.map +1 -0
- package/node_modules/@happier-dev/cli-common/dist/workspaces/index.js +80 -0
- package/node_modules/@happier-dev/cli-common/dist/workspaces/index.js.map +1 -0
- package/node_modules/@happier-dev/cli-common/package.json +26 -0
- package/package.json +77 -0
- package/scripts/auth.mjs +1829 -0
- package/scripts/auth_copy_from_pglite_lock_in_use.integration.test.mjs +90 -0
- package/scripts/auth_copy_from_runCapture.integration.test.mjs +447 -0
- package/scripts/auth_help_cmd.test.mjs +28 -0
- package/scripts/auth_login_flow_in_tty.test.mjs +100 -0
- package/scripts/auth_login_force_default.test.mjs +66 -0
- package/scripts/auth_login_guided_server_no_expo.test.mjs +126 -0
- package/scripts/auth_login_method_override.test.mjs +67 -0
- package/scripts/auth_login_print_includes_configure_links.test.mjs +99 -0
- package/scripts/auth_status_server_validation.integration.test.mjs +140 -0
- package/scripts/build.mjs +266 -0
- package/scripts/bundleWorkspaceDeps.mjs +38 -0
- package/scripts/bundleWorkspaceDeps.test.mjs +77 -0
- package/scripts/ci.mjs +135 -0
- package/scripts/ci.test.mjs +50 -0
- package/scripts/cli-link.mjs +57 -0
- package/scripts/completion.mjs +395 -0
- package/scripts/contrib.mjs +333 -0
- package/scripts/daemon.mjs +1160 -0
- package/scripts/daemon.status_scope.test.mjs +51 -0
- package/scripts/daemon_cmd.mjs +26 -0
- package/scripts/daemon_dist_guard.test.mjs +171 -0
- package/scripts/daemon_invalid_auth_reseed_stack_name.integration.test.mjs +608 -0
- package/scripts/daemon_server_scoped_state.test.mjs +49 -0
- package/scripts/daemon_start_verification.integration.test.mjs +296 -0
- package/scripts/dev.mjs +545 -0
- package/scripts/doctor.mjs +340 -0
- package/scripts/doctor_cmd.test.mjs +22 -0
- package/scripts/doctor_ui_index_missing.test.mjs +37 -0
- package/scripts/eas.mjs +367 -0
- package/scripts/eas_platform_parsing.test.mjs +63 -0
- package/scripts/edison.mjs +1848 -0
- package/scripts/env.mjs +149 -0
- package/scripts/env_cmd.test.mjs +118 -0
- package/scripts/exit_cleanup_kills_detached_children_on_crash.integration.test.mjs +80 -0
- package/scripts/happier.mjs +82 -0
- package/scripts/import.mjs +1327 -0
- package/scripts/init.mjs +464 -0
- package/scripts/install.mjs +550 -0
- package/scripts/lint.mjs +177 -0
- package/scripts/menubar.mjs +202 -0
- package/scripts/migrate.mjs +318 -0
- package/scripts/mobile.mjs +353 -0
- package/scripts/mobile_dev_client.mjs +87 -0
- package/scripts/monorepo.mjs +2234 -0
- package/scripts/monorepo_port.apply.integration.test.mjs +680 -0
- package/scripts/monorepo_port.conflicts.integration.test.mjs +454 -0
- package/scripts/monorepo_port.validation.integration.test.mjs +486 -0
- package/scripts/orchestrated_stack_auth_flow.test.mjs +134 -0
- package/scripts/orchestrated_stack_auth_flow_resolve_port.test.mjs +98 -0
- package/scripts/orchestrated_stack_auth_flow_webapp_url.test.mjs +119 -0
- package/scripts/pack.mjs +257 -0
- package/scripts/pack.test.mjs +68 -0
- package/scripts/pglite_lock.integration.test.mjs +152 -0
- package/scripts/provision/linux-ubuntu-e2e.sh +132 -0
- package/scripts/provision/linux-ubuntu-review-pr.sh +66 -0
- package/scripts/provision/macos-lima-happy-vm.sh +192 -0
- package/scripts/provision/macos-lima-hstack-e2e.sh +100 -0
- package/scripts/release.mjs +53 -0
- package/scripts/release_binary_smoke.integration.test.mjs +159 -0
- package/scripts/review.mjs +1752 -0
- package/scripts/review_pr.mjs +435 -0
- package/scripts/run.mjs +561 -0
- package/scripts/run_script_with_stack_env.restart_port_reuse.test.mjs +30 -0
- package/scripts/self.mjs +465 -0
- package/scripts/self_host.mjs +9 -0
- package/scripts/self_host_binary_smoke.integration.test.mjs +94 -0
- package/scripts/self_host_runtime.mjs +883 -0
- package/scripts/self_host_runtime.test.mjs +82 -0
- package/scripts/self_host_systemd.real.integration.test.mjs +367 -0
- package/scripts/server_flavor.mjs +148 -0
- package/scripts/service.mjs +868 -0
- package/scripts/service_mode_help.test.mjs +27 -0
- package/scripts/setup.mjs +1324 -0
- package/scripts/setup_non_interactive_flag.test.mjs +60 -0
- package/scripts/setup_pr.mjs +605 -0
- package/scripts/setup_pr_orchestrated_auth_flow_util_import.test.mjs +117 -0
- package/scripts/stack/command_arguments.mjs +91 -0
- package/scripts/stack/copy_auth_from_stack.mjs +111 -0
- package/scripts/stack/delegated_script_commands.mjs +92 -0
- package/scripts/stack/help_text.mjs +110 -0
- package/scripts/stack/port_reservation.mjs +74 -0
- package/scripts/stack/repo_checkout_resolution.mjs +31 -0
- package/scripts/stack/run_script_with_stack_env.mjs +634 -0
- package/scripts/stack/stack_daemon_command.mjs +219 -0
- package/scripts/stack/stack_delegated_help.mjs +81 -0
- package/scripts/stack/stack_environment.mjs +151 -0
- package/scripts/stack/stack_environment.sanitization.test.mjs +75 -0
- package/scripts/stack/stack_happier_passthrough_command.mjs +63 -0
- package/scripts/stack/stack_info_snapshot.mjs +167 -0
- package/scripts/stack/stack_mobile_install_command.mjs +61 -0
- package/scripts/stack/stack_resume_command.mjs +76 -0
- package/scripts/stack/stack_stop_command.mjs +34 -0
- package/scripts/stack/stack_workspace_command.mjs +83 -0
- package/scripts/stack/transient_repo_overrides.mjs +29 -0
- package/scripts/stack.mjs +2388 -0
- package/scripts/stack_archive_cmd.integration.test.mjs +31 -0
- package/scripts/stack_audit_fix_light_env.test.mjs +129 -0
- package/scripts/stack_background_pinned_stack_json.test.mjs +81 -0
- package/scripts/stack_copy_auth_server_scoped.test.mjs +243 -0
- package/scripts/stack_daemon_cmd.integration.test.mjs +484 -0
- package/scripts/stack_eas_help.test.mjs +72 -0
- package/scripts/stack_editor_workspace_monorepo_root.test.mjs +102 -0
- package/scripts/stack_env_cmd.test.mjs +107 -0
- package/scripts/stack_guided_login_bundle_error_parse.test.mjs +20 -0
- package/scripts/stack_guided_login_inner_invocation.test.mjs +46 -0
- package/scripts/stack_happy_cmd.integration.test.mjs +263 -0
- package/scripts/stack_info_snapshot_running_status.test.mjs +186 -0
- package/scripts/stack_interactive_monorepo_group.test.mjs +128 -0
- package/scripts/stack_monorepo_defaults.test.mjs +31 -0
- package/scripts/stack_monorepo_repo_dev_token.test.mjs +32 -0
- package/scripts/stack_monorepo_server_light_from_happy_spec.test.mjs +37 -0
- package/scripts/stack_new_name_normalize_cmd.test.mjs +38 -0
- package/scripts/stack_pr_name_normalize_cmd.test.mjs +84 -0
- package/scripts/stack_resume_cmd.integration.test.mjs +134 -0
- package/scripts/stack_server_flavors_defaults.test.mjs +64 -0
- package/scripts/stack_shorthand_cmd.integration.test.mjs +74 -0
- package/scripts/stack_stop_sweeps_legacy_infra_without_kind.integration.test.mjs +44 -0
- package/scripts/stack_stop_sweeps_when_runtime_missing.integration.test.mjs +42 -0
- package/scripts/stack_stop_sweeps_when_runtime_stale.integration.test.mjs +50 -0
- package/scripts/stack_wt_list.test.mjs +117 -0
- package/scripts/start_ui_required_default.test.mjs +63 -0
- package/scripts/stop.mjs +190 -0
- package/scripts/stopStackWithEnv_no_autosweep_when_runtime_missing.integration.test.mjs +95 -0
- package/scripts/swiftbar_git_monorepo_cmd.test.mjs +75 -0
- package/scripts/swiftbar_render_monorepo_wt_actions.integration.test.mjs +116 -0
- package/scripts/swiftbar_utils_cmd.test.mjs +92 -0
- package/scripts/swiftbar_wt_pr_backcompat.test.mjs +162 -0
- package/scripts/systemd_unit_info.test.mjs +24 -0
- package/scripts/tailscale.mjs +490 -0
- package/scripts/test_ci.mjs +36 -0
- package/scripts/test_cmd.mjs +274 -0
- package/scripts/test_cmd.test.mjs +133 -0
- package/scripts/test_integration.mjs +33 -0
- package/scripts/testkit/auth_testkit.mjs +121 -0
- package/scripts/testkit/doctor_testkit.mjs +68 -0
- package/scripts/testkit/monorepo_port_testkit.mjs +157 -0
- package/scripts/testkit/stack_archive_command_testkit.mjs +55 -0
- package/scripts/testkit/stack_new_monorepo_testkit.mjs +83 -0
- package/scripts/testkit/stack_script_command_testkit.mjs +27 -0
- package/scripts/testkit/stack_stop_sweeps_testkit.mjs +172 -0
- package/scripts/testkit/worktrees_monorepo_testkit.mjs +53 -0
- package/scripts/tools.mjs +70 -0
- package/scripts/tui.mjs +914 -0
- package/scripts/tui_stopStackForTuiExit_no_autosweep.integration.test.mjs +95 -0
- package/scripts/typecheck.mjs +178 -0
- package/scripts/ui_gateway.mjs +247 -0
- package/scripts/uninstall.mjs +179 -0
- package/scripts/utils/auth/credentials_paths.mjs +181 -0
- package/scripts/utils/auth/credentials_paths.test.mjs +187 -0
- package/scripts/utils/auth/daemon_gate.mjs +66 -0
- package/scripts/utils/auth/daemon_gate.test.mjs +116 -0
- package/scripts/utils/auth/decode_jwt_payload_unsafe.mjs +16 -0
- package/scripts/utils/auth/dev_key.mjs +163 -0
- package/scripts/utils/auth/files.mjs +56 -0
- package/scripts/utils/auth/guided_pr_auth.mjs +86 -0
- package/scripts/utils/auth/guided_stack_web_login.mjs +56 -0
- package/scripts/utils/auth/handy_master_secret.mjs +42 -0
- package/scripts/utils/auth/interactive_stack_auth.mjs +70 -0
- package/scripts/utils/auth/login_ux.mjs +105 -0
- package/scripts/utils/auth/orchestrated_stack_auth_flow.mjs +291 -0
- package/scripts/utils/auth/sources.mjs +28 -0
- package/scripts/utils/auth/stable_scope_id.mjs +91 -0
- package/scripts/utils/auth/stable_scope_id.test.mjs +51 -0
- package/scripts/utils/auth/stack_guided_login.mjs +438 -0
- package/scripts/utils/cli/arg_values.mjs +23 -0
- package/scripts/utils/cli/arg_values.test.mjs +43 -0
- package/scripts/utils/cli/args.mjs +17 -0
- package/scripts/utils/cli/cli.mjs +24 -0
- package/scripts/utils/cli/cli_registry.mjs +440 -0
- package/scripts/utils/cli/cwd_scope.mjs +158 -0
- package/scripts/utils/cli/cwd_scope.test.mjs +154 -0
- package/scripts/utils/cli/flags.mjs +17 -0
- package/scripts/utils/cli/log_forwarder.mjs +157 -0
- package/scripts/utils/cli/normalize.mjs +16 -0
- package/scripts/utils/cli/prereqs.mjs +103 -0
- package/scripts/utils/cli/prereqs.test.mjs +33 -0
- package/scripts/utils/cli/progress.mjs +141 -0
- package/scripts/utils/cli/smoke_help.mjs +44 -0
- package/scripts/utils/cli/verbosity.mjs +11 -0
- package/scripts/utils/cli/wizard.mjs +139 -0
- package/scripts/utils/cli/wizard_promptSelect.test.mjs +44 -0
- package/scripts/utils/cli/wizard_prompt_worktree_source_lazy.test.mjs +132 -0
- package/scripts/utils/cli/wizard_worktree_slug.test.mjs +33 -0
- package/scripts/utils/crypto/tokens.mjs +14 -0
- package/scripts/utils/dev/daemon.mjs +232 -0
- package/scripts/utils/dev/daemon_watch_resilience.test.mjs +224 -0
- package/scripts/utils/dev/expo_dev.buildEnv.test.mjs +35 -0
- package/scripts/utils/dev/expo_dev.mjs +478 -0
- package/scripts/utils/dev/expo_dev.test.mjs +89 -0
- package/scripts/utils/dev/expo_dev_restart_port_reservation.test.mjs +120 -0
- package/scripts/utils/dev/expo_dev_verbose_logs.test.mjs +60 -0
- package/scripts/utils/dev/server.mjs +180 -0
- package/scripts/utils/dev_auth_key.mjs +7 -0
- package/scripts/utils/edison/git_roots.mjs +30 -0
- package/scripts/utils/edison/git_roots.test.mjs +49 -0
- package/scripts/utils/env/config.mjs +52 -0
- package/scripts/utils/env/dotenv.mjs +32 -0
- package/scripts/utils/env/dotenv.test.mjs +32 -0
- package/scripts/utils/env/env.mjs +130 -0
- package/scripts/utils/env/env_file.mjs +98 -0
- package/scripts/utils/env/env_file.test.mjs +49 -0
- package/scripts/utils/env/env_local.mjs +25 -0
- package/scripts/utils/env/load_env_file.mjs +34 -0
- package/scripts/utils/env/read.mjs +30 -0
- package/scripts/utils/env/sandbox.mjs +13 -0
- package/scripts/utils/env/scrub_env.mjs +69 -0
- package/scripts/utils/env/scrub_env.test.mjs +102 -0
- package/scripts/utils/env/values.mjs +13 -0
- package/scripts/utils/expo/command.mjs +65 -0
- package/scripts/utils/expo/expo.mjs +139 -0
- package/scripts/utils/expo/expo_state_running.test.mjs +48 -0
- package/scripts/utils/expo/metro_ports.mjs +101 -0
- package/scripts/utils/expo/metro_ports.test.mjs +35 -0
- package/scripts/utils/fs/atomic_dir_swap.mjs +55 -0
- package/scripts/utils/fs/atomic_dir_swap.test.mjs +54 -0
- package/scripts/utils/fs/file_has_content.mjs +10 -0
- package/scripts/utils/fs/fs.mjs +11 -0
- package/scripts/utils/fs/json.mjs +25 -0
- package/scripts/utils/fs/ops.mjs +29 -0
- package/scripts/utils/fs/package_json.mjs +8 -0
- package/scripts/utils/fs/tail.mjs +12 -0
- package/scripts/utils/git/dev_checkout.mjs +127 -0
- package/scripts/utils/git/dev_checkout.test.mjs +115 -0
- package/scripts/utils/git/git.mjs +67 -0
- package/scripts/utils/git/parse_name_status_z.mjs +21 -0
- package/scripts/utils/git/refs.mjs +26 -0
- package/scripts/utils/git/worktrees.mjs +323 -0
- package/scripts/utils/git/worktrees_monorepo.test.mjs +60 -0
- package/scripts/utils/git/worktrees_pathstyle.test.mjs +53 -0
- package/scripts/utils/llm/assist.mjs +260 -0
- package/scripts/utils/llm/codex_exec.mjs +61 -0
- package/scripts/utils/llm/codex_exec.test.mjs +46 -0
- package/scripts/utils/llm/hstack_runner.mjs +59 -0
- package/scripts/utils/llm/tools.mjs +56 -0
- package/scripts/utils/llm/tools.test.mjs +67 -0
- package/scripts/utils/menubar/swiftbar.mjs +121 -0
- package/scripts/utils/menubar/swiftbar.test.mjs +85 -0
- package/scripts/utils/mobile/config.mjs +35 -0
- package/scripts/utils/mobile/dev_client_links.mjs +59 -0
- package/scripts/utils/mobile/identifiers.mjs +46 -0
- package/scripts/utils/mobile/identifiers.test.mjs +41 -0
- package/scripts/utils/mobile/ios_xcodeproj_patch.mjs +128 -0
- package/scripts/utils/mobile/ios_xcodeproj_patch.test.mjs +131 -0
- package/scripts/utils/net/bind_mode.mjs +39 -0
- package/scripts/utils/net/dns.mjs +10 -0
- package/scripts/utils/net/lan_ip.mjs +24 -0
- package/scripts/utils/net/ports.mjs +110 -0
- package/scripts/utils/net/tcp_forward.mjs +162 -0
- package/scripts/utils/net/url.mjs +30 -0
- package/scripts/utils/net/url.test.mjs +29 -0
- package/scripts/utils/paths/canonical_home.mjs +15 -0
- package/scripts/utils/paths/canonical_home.test.mjs +28 -0
- package/scripts/utils/paths/localhost_host.mjs +112 -0
- package/scripts/utils/paths/localhost_host.test.mjs +58 -0
- package/scripts/utils/paths/paths.mjs +302 -0
- package/scripts/utils/paths/paths_env_win32.test.mjs +36 -0
- package/scripts/utils/paths/paths_monorepo.test.mjs +58 -0
- package/scripts/utils/paths/paths_server_flavors.test.mjs +50 -0
- package/scripts/utils/paths/runtime.mjs +41 -0
- package/scripts/utils/pglite_lock.mjs +107 -0
- package/scripts/utils/proc/commands.mjs +33 -0
- package/scripts/utils/proc/exit_cleanup.mjs +57 -0
- package/scripts/utils/proc/happy_monorepo_deps.mjs +37 -0
- package/scripts/utils/proc/happy_monorepo_deps.test.mjs +89 -0
- package/scripts/utils/proc/ownership.mjs +217 -0
- package/scripts/utils/proc/ownership_killProcessGroupOwnedByStack.test.mjs +216 -0
- package/scripts/utils/proc/ownership_listPidsWithEnvNeedles.test.mjs +88 -0
- package/scripts/utils/proc/package_scripts.mjs +38 -0
- package/scripts/utils/proc/package_scripts.test.mjs +58 -0
- package/scripts/utils/proc/parallel.mjs +25 -0
- package/scripts/utils/proc/pids.mjs +11 -0
- package/scripts/utils/proc/pm.mjs +478 -0
- package/scripts/utils/proc/pm_spawn.integration.test.mjs +131 -0
- package/scripts/utils/proc/pm_stack_cache_env.test.mjs +313 -0
- package/scripts/utils/proc/proc.mjs +331 -0
- package/scripts/utils/proc/proc.test.mjs +85 -0
- package/scripts/utils/proc/terminate.mjs +69 -0
- package/scripts/utils/proc/terminate.test.mjs +54 -0
- package/scripts/utils/proc/watch.mjs +63 -0
- package/scripts/utils/review/augment_runner_integration.test.mjs +105 -0
- package/scripts/utils/review/base_ref.mjs +82 -0
- package/scripts/utils/review/base_ref.test.mjs +89 -0
- package/scripts/utils/review/chunks.mjs +55 -0
- package/scripts/utils/review/chunks.test.mjs +107 -0
- package/scripts/utils/review/detached_worktree.mjs +61 -0
- package/scripts/utils/review/detached_worktree.test.mjs +61 -0
- package/scripts/utils/review/findings.mjs +278 -0
- package/scripts/utils/review/findings.test.mjs +203 -0
- package/scripts/utils/review/head_slice.mjs +132 -0
- package/scripts/utils/review/head_slice.test.mjs +117 -0
- package/scripts/utils/review/instructions/deep.md +20 -0
- package/scripts/utils/review/prompts.mjs +279 -0
- package/scripts/utils/review/prompts.test.mjs +77 -0
- package/scripts/utils/review/run_reviewers_safe.mjs +12 -0
- package/scripts/utils/review/run_reviewers_safe.test.mjs +45 -0
- package/scripts/utils/review/runners/augment.mjs +91 -0
- package/scripts/utils/review/runners/augment.test.mjs +64 -0
- package/scripts/utils/review/runners/claude.mjs +92 -0
- package/scripts/utils/review/runners/claude.test.mjs +47 -0
- package/scripts/utils/review/runners/coderabbit.mjs +105 -0
- package/scripts/utils/review/runners/coderabbit.test.mjs +32 -0
- package/scripts/utils/review/runners/codex.mjs +129 -0
- package/scripts/utils/review/runners/codex.test.mjs +115 -0
- package/scripts/utils/review/slice_mode.mjs +20 -0
- package/scripts/utils/review/slice_mode.test.mjs +69 -0
- package/scripts/utils/review/sliced_runner.mjs +39 -0
- package/scripts/utils/review/sliced_runner.test.mjs +57 -0
- package/scripts/utils/review/slices.mjs +140 -0
- package/scripts/utils/review/slices.test.mjs +41 -0
- package/scripts/utils/review/targets.mjs +23 -0
- package/scripts/utils/review/targets.test.mjs +31 -0
- package/scripts/utils/review/tool_home_seed.mjs +106 -0
- package/scripts/utils/review/tool_home_seed.test.mjs +124 -0
- package/scripts/utils/review/uncommitted_ops.mjs +77 -0
- package/scripts/utils/review/uncommitted_ops.test.mjs +117 -0
- package/scripts/utils/sandbox/review_pr_sandbox.mjs +105 -0
- package/scripts/utils/server/apply_server_light_env_defaults.mjs +14 -0
- package/scripts/utils/server/flavor_scripts.mjs +138 -0
- package/scripts/utils/server/flavor_scripts.test.mjs +115 -0
- package/scripts/utils/server/infra/happy_server_infra.mjs +444 -0
- package/scripts/utils/server/mobile_api_url.mjs +60 -0
- package/scripts/utils/server/mobile_api_url.test.mjs +58 -0
- package/scripts/utils/server/port.mjs +55 -0
- package/scripts/utils/server/prisma_import.mjs +36 -0
- package/scripts/utils/server/prisma_import.test.mjs +78 -0
- package/scripts/utils/server/server.mjs +109 -0
- package/scripts/utils/server/ui_build_check.mjs +37 -0
- package/scripts/utils/server/ui_build_check.test.mjs +70 -0
- package/scripts/utils/server/ui_env.mjs +13 -0
- package/scripts/utils/server/ui_env.test.mjs +57 -0
- package/scripts/utils/server/urls.mjs +100 -0
- package/scripts/utils/server/validate.mjs +60 -0
- package/scripts/utils/server/validate.test.mjs +76 -0
- package/scripts/utils/service/autostart_darwin.mjs +198 -0
- package/scripts/utils/service/autostart_darwin.test.mjs +49 -0
- package/scripts/utils/service/autostart_darwin_keepalive.test.mjs +19 -0
- package/scripts/utils/stack/cli_identities.mjs +29 -0
- package/scripts/utils/stack/context.mjs +19 -0
- package/scripts/utils/stack/dirs.mjs +26 -0
- package/scripts/utils/stack/editor_workspace.mjs +126 -0
- package/scripts/utils/stack/interactive_stack_config.mjs +266 -0
- package/scripts/utils/stack/interactive_stack_config.port_validation.test.mjs +93 -0
- package/scripts/utils/stack/interactive_stack_config.remote_validation.test.mjs +122 -0
- package/scripts/utils/stack/interactive_stack_config.stack_name_validation.test.mjs +76 -0
- package/scripts/utils/stack/interactive_stack_config_testkit.mjs +18 -0
- package/scripts/utils/stack/names.mjs +27 -0
- package/scripts/utils/stack/names.test.mjs +26 -0
- package/scripts/utils/stack/pr_stack_name.mjs +16 -0
- package/scripts/utils/stack/runtime_state.mjs +88 -0
- package/scripts/utils/stack/stacks.mjs +40 -0
- package/scripts/utils/stack/startup.mjs +370 -0
- package/scripts/utils/stack/startup_server_light_dirs.test.mjs +119 -0
- package/scripts/utils/stack/startup_server_light_generate.test.mjs +20 -0
- package/scripts/utils/stack/startup_server_light_legacy.test.mjs +79 -0
- package/scripts/utils/stack/startup_server_light_testkit.mjs +106 -0
- package/scripts/utils/stack/stop.mjs +284 -0
- package/scripts/utils/stack_context.mjs +1 -0
- package/scripts/utils/stack_runtime_state.mjs +1 -0
- package/scripts/utils/stacks.mjs +1 -0
- package/scripts/utils/tailscale/ip.mjs +116 -0
- package/scripts/utils/tauri/stack_overrides.mjs +22 -0
- package/scripts/utils/test/collect_test_files.mjs +29 -0
- package/scripts/utils/time/get_today_ymd.mjs +7 -0
- package/scripts/utils/tui/cleanup.mjs +38 -0
- package/scripts/utils/ui/ansi.mjs +47 -0
- package/scripts/utils/ui/browser.mjs +31 -0
- package/scripts/utils/ui/browser.test.mjs +56 -0
- package/scripts/utils/ui/clipboard.mjs +38 -0
- package/scripts/utils/ui/layout.mjs +44 -0
- package/scripts/utils/ui/qr.mjs +17 -0
- package/scripts/utils/ui/terminal_launcher.mjs +129 -0
- package/scripts/utils/ui/text.mjs +16 -0
- package/scripts/utils/update/auto_update_notice.mjs +93 -0
- package/scripts/utils/validate.mjs +5 -0
- package/scripts/where.mjs +138 -0
- package/scripts/worktrees.mjs +2174 -0
- package/scripts/worktrees_archive_cmd.integration.test.mjs +228 -0
- package/scripts/worktrees_cursor_monorepo_root.test.mjs +23 -0
- package/scripts/worktrees_list_specs_no_recurse.test.mjs +32 -0
- package/scripts/worktrees_monorepo_testkit.test.mjs +29 -0
- package/scripts/worktrees_monorepo_use_group.test.mjs +41 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
|
|
3
|
+
import { parseEnvToObject } from '../env/dotenv.mjs';
|
|
4
|
+
import { resolveStackEnvPath } from '../paths/paths.mjs';
|
|
5
|
+
import { stopStackWithEnv } from '../stack/stop.mjs';
|
|
6
|
+
|
|
7
|
+
async function readEnvObject(envPath) {
|
|
8
|
+
try {
|
|
9
|
+
const raw = await readFile(envPath, 'utf-8');
|
|
10
|
+
return parseEnvToObject(raw);
|
|
11
|
+
} catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function stopStackForTuiExit({ rootDir, stackName, json = false, noDocker = false, env: outerEnv = process.env }) {
|
|
17
|
+
const { envPath, baseDir } = resolveStackEnvPath(stackName, outerEnv);
|
|
18
|
+
const stackEnv = await readEnvObject(envPath);
|
|
19
|
+
|
|
20
|
+
const env = {
|
|
21
|
+
...(outerEnv ?? process.env),
|
|
22
|
+
...stackEnv,
|
|
23
|
+
HAPPIER_STACK_STACK: stackName,
|
|
24
|
+
HAPPIER_STACK_ENV_FILE: envPath,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return await stopStackWithEnv({
|
|
28
|
+
rootDir,
|
|
29
|
+
stackName,
|
|
30
|
+
baseDir,
|
|
31
|
+
env,
|
|
32
|
+
json,
|
|
33
|
+
noDocker,
|
|
34
|
+
aggressive: false,
|
|
35
|
+
sweepOwned: false,
|
|
36
|
+
autoSweep: true,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
function supportsAnsi() {
|
|
2
|
+
if (!process.stdout.isTTY) return false;
|
|
3
|
+
if (process.env.NO_COLOR) return false;
|
|
4
|
+
if ((process.env.TERM ?? '').toLowerCase() === 'dumb') return false;
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function wrap(code, s) {
|
|
9
|
+
return supportsAnsi() ? `\x1b[${code}m${s}\x1b[0m` : String(s);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ansiEnabled() {
|
|
13
|
+
return supportsAnsi();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function bold(s) {
|
|
17
|
+
return wrap('1', s);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function dim(s) {
|
|
21
|
+
return wrap('2', s);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function red(s) {
|
|
25
|
+
return wrap('31', s);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function green(s) {
|
|
29
|
+
return wrap('32', s);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function yellow(s) {
|
|
33
|
+
return wrap('33', s);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function blue(s) {
|
|
37
|
+
return wrap('34', s);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function magenta(s) {
|
|
41
|
+
return wrap('35', s);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function cyan(s) {
|
|
45
|
+
return wrap('36', s);
|
|
46
|
+
}
|
|
47
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { runCapture } from '../proc/proc.mjs';
|
|
2
|
+
|
|
3
|
+
function isTruthyEnvValue(value) {
|
|
4
|
+
const raw = String(value ?? '').trim().toLowerCase();
|
|
5
|
+
if (!raw) return false;
|
|
6
|
+
return raw !== '0' && raw !== 'false';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function openUrlInBrowser(url, { timeoutMs = 5_000 } = {}) {
|
|
10
|
+
const u = String(url ?? '').trim();
|
|
11
|
+
if (!u) return { ok: false, error: 'missing_url' };
|
|
12
|
+
if (isTruthyEnvValue(process.env.HAPPIER_NO_BROWSER_OPEN) || isTruthyEnvValue(process.env.HAPPIER_STACK_NO_BROWSER)) {
|
|
13
|
+
return { ok: false, error: 'browser_open_disabled' };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
if (process.platform === 'darwin') {
|
|
18
|
+
await runCapture('open', [u], { timeoutMs });
|
|
19
|
+
return { ok: true, method: 'open' };
|
|
20
|
+
}
|
|
21
|
+
if (process.platform === 'win32') {
|
|
22
|
+
// `start` is a cmd built-in; the empty title ("") is required so URLs with :// don't get treated as a title.
|
|
23
|
+
await runCapture('cmd', ['/c', 'start', '""', u], { timeoutMs });
|
|
24
|
+
return { ok: true, method: 'cmd-start' };
|
|
25
|
+
}
|
|
26
|
+
await runCapture('xdg-open', [u], { timeoutMs });
|
|
27
|
+
return { ok: true, method: 'xdg-open' };
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { mkdtemp, writeFile, readFile, rm } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join, dirname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { spawnSync } from 'node:child_process';
|
|
8
|
+
|
|
9
|
+
function readTextOrEmpty(path) {
|
|
10
|
+
return readFile(path, 'utf-8').catch(() => '');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
test('openUrlInBrowser respects HAPPIER_NO_BROWSER_OPEN and does not invoke OS opener', async (t) => {
|
|
14
|
+
if (process.platform === 'win32') {
|
|
15
|
+
t.skip('uses shell shims tailored for POSIX openers');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const tmp = await mkdtemp(join(tmpdir(), 'hstack-browser-open-'));
|
|
20
|
+
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const pathSep = process.platform === 'win32' ? ';' : ':';
|
|
22
|
+
const openLogPath = join(tmp, 'open.log');
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const shim = '#!/usr/bin/env bash\nprintf "%s\\n" "$@" >> "$OPEN_LOG"\n';
|
|
26
|
+
await writeFile(join(tmp, 'open'), shim, { mode: 0o755 });
|
|
27
|
+
await writeFile(join(tmp, 'xdg-open'), shim, { mode: 0o755 });
|
|
28
|
+
|
|
29
|
+
const child = spawnSync(
|
|
30
|
+
process.execPath,
|
|
31
|
+
[
|
|
32
|
+
'--input-type=module',
|
|
33
|
+
'-e',
|
|
34
|
+
"import { openUrlInBrowser } from './browser.mjs'; const res = await openUrlInBrowser('http://localhost:54545'); process.stdout.write(JSON.stringify(res));",
|
|
35
|
+
],
|
|
36
|
+
{
|
|
37
|
+
cwd: scriptDir,
|
|
38
|
+
env: {
|
|
39
|
+
...process.env,
|
|
40
|
+
PATH: `${tmp}${pathSep}${process.env.PATH ?? ''}`,
|
|
41
|
+
OPEN_LOG: openLogPath,
|
|
42
|
+
HAPPIER_NO_BROWSER_OPEN: '1',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
assert.equal(child.status, 0, `stdout:\n${child.stdout}\nstderr:\n${child.stderr}`);
|
|
48
|
+
const stdoutText = String(child.stdout ?? '').trim();
|
|
49
|
+
const parsed = JSON.parse(stdoutText || '{}');
|
|
50
|
+
assert.equal(parsed.ok, false, `expected openUrlInBrowser to skip open\nstdout:\n${child.stdout}`);
|
|
51
|
+
const logContents = await readTextOrEmpty(openLogPath);
|
|
52
|
+
assert.equal(logContents.trim(), '', `expected no OS opener invocations\nlog:\n${logContents}`);
|
|
53
|
+
} finally {
|
|
54
|
+
await rm(tmp, { recursive: true, force: true }).catch(() => {});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { commandExists } from '../proc/commands.mjs';
|
|
2
|
+
import { run } from '../proc/proc.mjs';
|
|
3
|
+
|
|
4
|
+
export async function clipboardAvailable() {
|
|
5
|
+
if (process.platform === 'darwin') {
|
|
6
|
+
return await commandExists('pbcopy');
|
|
7
|
+
}
|
|
8
|
+
if (process.platform === 'linux') {
|
|
9
|
+
return (await commandExists('wl-copy')) || (await commandExists('xclip'));
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function copyTextToClipboard(text) {
|
|
15
|
+
const s = String(text ?? '');
|
|
16
|
+
if (!s) return { ok: false, reason: 'empty' };
|
|
17
|
+
|
|
18
|
+
if (process.platform === 'darwin') {
|
|
19
|
+
if (!(await commandExists('pbcopy'))) return { ok: false, reason: 'pbcopy not found' };
|
|
20
|
+
await run('pbcopy', [], { input: s });
|
|
21
|
+
return { ok: true };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (process.platform === 'linux') {
|
|
25
|
+
if (await commandExists('wl-copy')) {
|
|
26
|
+
await run('wl-copy', [], { input: s });
|
|
27
|
+
return { ok: true };
|
|
28
|
+
}
|
|
29
|
+
if (await commandExists('xclip')) {
|
|
30
|
+
await run('xclip', ['-selection', 'clipboard'], { input: s });
|
|
31
|
+
return { ok: true };
|
|
32
|
+
}
|
|
33
|
+
return { ok: false, reason: 'no clipboard tool found' };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { ok: false, reason: `unsupported platform: ${process.platform}` };
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ansiEnabled, bold, cyan, dim, green, red, yellow } from './ansi.mjs';
|
|
2
|
+
|
|
3
|
+
function icon(s) {
|
|
4
|
+
// Keep icons TTY-friendly; avoid icons when color is disabled to reduce noise in logs.
|
|
5
|
+
return ansiEnabled() ? String(s) : '';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function cmd(s) {
|
|
9
|
+
return yellow(String(s));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ok(s) {
|
|
13
|
+
return `${green('✓')}${s ? ` ${s}` : ''}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function warn(s) {
|
|
17
|
+
return `${yellow('!')}${s ? ` ${s}` : ''}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function fail(s) {
|
|
21
|
+
return `${red('x')}${s ? ` ${s}` : ''}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function kv(label, value) {
|
|
25
|
+
return `${dim(label)} ${value}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function sectionTitle(title) {
|
|
29
|
+
return bold(String(title));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function banner(title, { subtitle = '', prefix = '✨', suffix = '✨' } = {}) {
|
|
33
|
+
const pre = icon(prefix);
|
|
34
|
+
const suf = icon(suffix);
|
|
35
|
+
const t = `${pre ? `${pre} ` : ''}${cyan(title)}${suf ? ` ${suf}` : ''}`;
|
|
36
|
+
const lines = [bold(t)];
|
|
37
|
+
if (subtitle) lines.push(dim(subtitle));
|
|
38
|
+
return lines.join('\n');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function bullets(lines) {
|
|
42
|
+
return (lines ?? []).map((l) => `- ${l}`).join('\n');
|
|
43
|
+
}
|
|
44
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import qrcodeTerminal from 'qrcode-terminal';
|
|
2
|
+
|
|
3
|
+
export async function renderQrAscii(text, { small = true } = {}) {
|
|
4
|
+
const qrText = String(text ?? '');
|
|
5
|
+
if (!qrText) return { ok: false, lines: [], error: 'empty QR payload' };
|
|
6
|
+
try {
|
|
7
|
+
const out = await new Promise((resolvePromise) => {
|
|
8
|
+
qrcodeTerminal.generate(qrText, { small: Boolean(small) }, (qr) => resolvePromise(String(qr ?? '')));
|
|
9
|
+
});
|
|
10
|
+
// Important: keep whitespace; scanners rely on quiet-zone padding.
|
|
11
|
+
const lines = String(out ?? '').replace(/\r/g, '').split('\n');
|
|
12
|
+
return { ok: true, lines, error: null };
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return { ok: false, lines: [], error: e instanceof Error ? e.message : String(e) };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { commandExists } from '../proc/commands.mjs';
|
|
2
|
+
import { run } from '../proc/proc.mjs';
|
|
3
|
+
import { chmod, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
|
|
7
|
+
function hasGuiSession(env = process.env) {
|
|
8
|
+
if (process.platform === 'darwin') return true;
|
|
9
|
+
if (process.platform === 'linux') {
|
|
10
|
+
const display = String(env.DISPLAY ?? '').trim();
|
|
11
|
+
const wayland = String(env.WAYLAND_DISPLAY ?? '').trim();
|
|
12
|
+
return Boolean(display || wayland);
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function pickLinuxTerminalCmd() {
|
|
18
|
+
// Best-effort: pick the first terminal emulator we can find.
|
|
19
|
+
const candidates = [
|
|
20
|
+
'x-terminal-emulator', // Debian/Ubuntu alternatives
|
|
21
|
+
'gnome-terminal',
|
|
22
|
+
'konsole',
|
|
23
|
+
'xfce4-terminal',
|
|
24
|
+
'kitty',
|
|
25
|
+
'wezterm',
|
|
26
|
+
'alacritty',
|
|
27
|
+
'xterm',
|
|
28
|
+
];
|
|
29
|
+
for (const c of candidates) {
|
|
30
|
+
// eslint-disable-next-line no-await-in-loop
|
|
31
|
+
if (await commandExists(c)) return c;
|
|
32
|
+
}
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function linuxTerminalArgs(cmd, scriptPath) {
|
|
37
|
+
// Keep this conservative and use `bash` explicitly.
|
|
38
|
+
switch (cmd) {
|
|
39
|
+
case 'gnome-terminal':
|
|
40
|
+
return ['--', 'bash', scriptPath];
|
|
41
|
+
case 'konsole':
|
|
42
|
+
return ['-e', 'bash', scriptPath];
|
|
43
|
+
case 'xfce4-terminal':
|
|
44
|
+
return ['--disable-server', '--command', `bash "${scriptPath.replace(/"/g, '\\"')}"`];
|
|
45
|
+
case 'wezterm':
|
|
46
|
+
return ['start', '--', 'bash', scriptPath];
|
|
47
|
+
case 'alacritty':
|
|
48
|
+
return ['-e', 'bash', scriptPath];
|
|
49
|
+
case 'kitty':
|
|
50
|
+
return ['bash', scriptPath];
|
|
51
|
+
case 'xterm':
|
|
52
|
+
return ['-e', 'bash', scriptPath];
|
|
53
|
+
case 'x-terminal-emulator':
|
|
54
|
+
return ['-e', 'bash', scriptPath];
|
|
55
|
+
default:
|
|
56
|
+
return ['-e', 'bash', scriptPath];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function escapeAppleScriptString(s) {
|
|
61
|
+
return String(s ?? '')
|
|
62
|
+
.replace(/\\/g, '\\\\')
|
|
63
|
+
.replace(/"/g, '\\"')
|
|
64
|
+
.replace(/\n/g, '\\n');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function canLaunchNewTerminal({ env } = {}) {
|
|
68
|
+
const e = env ?? process.env;
|
|
69
|
+
if (!hasGuiSession(e)) return { ok: false, reason: 'no GUI session detected' };
|
|
70
|
+
if (process.platform === 'darwin') {
|
|
71
|
+
const hasOsascript = await commandExists('osascript', { env: e });
|
|
72
|
+
if (!hasOsascript) return { ok: false, reason: 'osascript not found' };
|
|
73
|
+
return { ok: true, kind: 'darwin-terminal' };
|
|
74
|
+
}
|
|
75
|
+
if (process.platform === 'linux') {
|
|
76
|
+
const term = await pickLinuxTerminalCmd();
|
|
77
|
+
if (!term) return { ok: false, reason: 'no terminal emulator found' };
|
|
78
|
+
return { ok: true, kind: 'linux-terminal', terminalCmd: term };
|
|
79
|
+
}
|
|
80
|
+
return { ok: false, reason: `unsupported platform: ${process.platform}` };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function launchScriptInNewTerminal({ scriptText, title, env } = {}) {
|
|
84
|
+
const e = env ?? process.env;
|
|
85
|
+
const support = await canLaunchNewTerminal({ env: e });
|
|
86
|
+
if (!support.ok) return { ok: false, reason: support.reason };
|
|
87
|
+
|
|
88
|
+
const dir = await mkdtemp(join(tmpdir(), 'happy-stacks-llm-'));
|
|
89
|
+
const scriptPath = join(dir, 'run.sh');
|
|
90
|
+
const text = [
|
|
91
|
+
String(scriptText ?? '').trimEnd(),
|
|
92
|
+
'',
|
|
93
|
+
// Self-cleanup best-effort.
|
|
94
|
+
'rm -f "$0" >/dev/null 2>&1 || true',
|
|
95
|
+
'rmdir "$(dirname "$0")" >/dev/null 2>&1 || true',
|
|
96
|
+
'',
|
|
97
|
+
].join('\n');
|
|
98
|
+
|
|
99
|
+
await writeFile(scriptPath, text, 'utf-8');
|
|
100
|
+
await chmod(scriptPath, 0o755);
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
if (support.kind === 'darwin-terminal') {
|
|
104
|
+
const banner = title ? `echo ${JSON.stringify(String(title))}; echo; ` : '';
|
|
105
|
+
const cmd = `${banner}bash "${scriptPath}"`;
|
|
106
|
+
const as = [
|
|
107
|
+
'tell application "Terminal"',
|
|
108
|
+
'activate',
|
|
109
|
+
`do script "${escapeAppleScriptString(cmd)}"`,
|
|
110
|
+
'end tell',
|
|
111
|
+
].join('\n');
|
|
112
|
+
await run('osascript', ['-e', as], { env: e });
|
|
113
|
+
return { ok: true, launched: true };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (support.kind === 'linux-terminal') {
|
|
117
|
+
const args = linuxTerminalArgs(support.terminalCmd, scriptPath);
|
|
118
|
+
await run(support.terminalCmd, args, { env: e });
|
|
119
|
+
return { ok: true, launched: true, terminalCmd: support.terminalCmd };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return { ok: false, reason: 'unknown terminal kind' };
|
|
123
|
+
} catch (err) {
|
|
124
|
+
// Cleanup, since the script didn't launch.
|
|
125
|
+
await rm(dir, { recursive: true, force: true }).catch(() => {});
|
|
126
|
+
return { ok: false, reason: String(err?.message ?? err ?? 'launch failed') };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function stripAnsi(s) {
|
|
2
|
+
// eslint-disable-next-line no-control-regex
|
|
3
|
+
return String(s ?? '').replace(/\x1b\[[0-9;]*[A-Za-z]/g, '');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function padRight(s, n) {
|
|
7
|
+
const str = String(s ?? '');
|
|
8
|
+
if (str.length >= n) return str.slice(0, n);
|
|
9
|
+
return str + ' '.repeat(n - str.length);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function parsePrefixedLabel(line) {
|
|
13
|
+
const m = String(line ?? '').match(/^\[([^\]]+)\]\s*/);
|
|
14
|
+
return m ? m[1] : null;
|
|
15
|
+
}
|
|
16
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
acquireSingleFlightLock,
|
|
5
|
+
formatUpdateNotice,
|
|
6
|
+
readUpdateCache,
|
|
7
|
+
shouldNotifyUpdate,
|
|
8
|
+
spawnDetachedNode,
|
|
9
|
+
writeUpdateCache,
|
|
10
|
+
} from '@happier-dev/cli-common/update';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_CHECK_LOCK_TTL_MS = 2 * 60 * 1000;
|
|
13
|
+
const DEFAULT_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
14
|
+
|
|
15
|
+
function parseEnabledFlag(raw, { defaultValue = true } = {}) {
|
|
16
|
+
const v = String(raw ?? '').trim().toLowerCase();
|
|
17
|
+
if (!v) return defaultValue;
|
|
18
|
+
if (v === '0' || v === 'false' || v === 'no' || v === 'off') return false;
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parsePositiveMs(raw, fallback) {
|
|
23
|
+
const v = String(raw ?? '').trim();
|
|
24
|
+
if (!v) return fallback;
|
|
25
|
+
const n = Number(v);
|
|
26
|
+
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function maybeAutoUpdateNotice({
|
|
30
|
+
cliRootDir,
|
|
31
|
+
cmd,
|
|
32
|
+
homeDir,
|
|
33
|
+
isTTY,
|
|
34
|
+
env,
|
|
35
|
+
nowMs,
|
|
36
|
+
spawnDetached = spawnDetachedNode,
|
|
37
|
+
log = console.error,
|
|
38
|
+
}) {
|
|
39
|
+
const enabled = parseEnabledFlag(env.HAPPIER_STACK_UPDATE_CHECK, { defaultValue: true });
|
|
40
|
+
if (!enabled) return;
|
|
41
|
+
if (!isTTY) return;
|
|
42
|
+
if (env.HAPPIER_STACK_UPDATE_CHECK_SPAWNED === '1') return;
|
|
43
|
+
if (cmd === 'self' || cmd === 'help' || cmd === '--help' || cmd === '-h') return;
|
|
44
|
+
|
|
45
|
+
const cachePath = join(homeDir, 'cache', 'update.json');
|
|
46
|
+
|
|
47
|
+
const intervalMs = parsePositiveMs(env.HAPPIER_STACK_UPDATE_CHECK_INTERVAL_MS, DEFAULT_INTERVAL_MS);
|
|
48
|
+
const notifyIntervalMs = parsePositiveMs(env.HAPPIER_STACK_UPDATE_NOTIFY_INTERVAL_MS, DEFAULT_INTERVAL_MS);
|
|
49
|
+
|
|
50
|
+
const cached = readUpdateCache(cachePath);
|
|
51
|
+
|
|
52
|
+
const now = nowMs ?? Date.now();
|
|
53
|
+
const checkedAt = typeof cached?.checkedAt === 'number' ? cached.checkedAt : 0;
|
|
54
|
+
const shouldCheck = !checkedAt || (now - checkedAt > intervalMs);
|
|
55
|
+
|
|
56
|
+
const shouldNotify = shouldNotifyUpdate({
|
|
57
|
+
isTTY,
|
|
58
|
+
cmd,
|
|
59
|
+
updateAvailable: Boolean(cached?.updateAvailable),
|
|
60
|
+
latest: cached?.latest ?? null,
|
|
61
|
+
notifiedAt: cached?.notifiedAt ?? null,
|
|
62
|
+
notifyIntervalMs,
|
|
63
|
+
nowMs: now,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (shouldNotify) {
|
|
67
|
+
const from = cached?.current ? cached.current : 'current';
|
|
68
|
+
const to = cached?.latest ?? 'latest';
|
|
69
|
+
log(formatUpdateNotice({ toolName: 'hstack', from, to, updateCommand: 'hstack self update' }));
|
|
70
|
+
writeUpdateCache(cachePath, {
|
|
71
|
+
checkedAt: cached?.checkedAt ?? null,
|
|
72
|
+
latest: cached?.latest ?? null,
|
|
73
|
+
current: cached?.current ?? null,
|
|
74
|
+
runtimeVersion: cached?.runtimeVersion ?? null,
|
|
75
|
+
invokerVersion: cached?.invokerVersion ?? null,
|
|
76
|
+
updateAvailable: Boolean(cached?.updateAvailable),
|
|
77
|
+
notifiedAt: now,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!shouldCheck) return;
|
|
82
|
+
|
|
83
|
+
const lockTtlMs = parsePositiveMs(env.HAPPIER_STACK_UPDATE_CHECK_LOCK_TTL_MS, DEFAULT_CHECK_LOCK_TTL_MS);
|
|
84
|
+
const lockPath = join(homeDir, 'cache', 'update.check.lock.json');
|
|
85
|
+
if (!acquireSingleFlightLock({ lockPath, nowMs: now, ttlMs: lockTtlMs, pid: process.pid })) return;
|
|
86
|
+
|
|
87
|
+
spawnDetached({
|
|
88
|
+
script: join(cliRootDir, 'scripts', 'self.mjs'),
|
|
89
|
+
args: ['check', '--quiet'],
|
|
90
|
+
cwd: cliRootDir,
|
|
91
|
+
env: { ...env, HAPPIER_STACK_UPDATE_CHECK_SPAWNED: '1' },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import './utils/env/env.mjs';
|
|
2
|
+
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
import { parseArgs } from './utils/cli/args.mjs';
|
|
7
|
+
import { expandHome } from './utils/paths/canonical_home.mjs';
|
|
8
|
+
import { getComponentDir, getDevRepoDir, getHappyStacksHomeDir, getRepoDir, getRootDir, getStackLabel, getStackName, getWorkspaceDir, resolveStackEnvPath } from './utils/paths/paths.mjs';
|
|
9
|
+
import { printResult, wantsHelp, wantsJson } from './utils/cli/cli.mjs';
|
|
10
|
+
import { getRuntimeDir } from './utils/paths/runtime.mjs';
|
|
11
|
+
import { getCanonicalHomeDir, getCanonicalHomeEnvPath } from './utils/env/config.mjs';
|
|
12
|
+
import { getSandboxDir } from './utils/env/sandbox.mjs';
|
|
13
|
+
import { banner, bullets, kv, sectionTitle } from './utils/ui/layout.mjs';
|
|
14
|
+
import { cyan, dim } from './utils/ui/ansi.mjs';
|
|
15
|
+
import { WORKTREE_CATEGORIES, getWorktreeCategoryRoot } from './utils/git/worktrees.mjs';
|
|
16
|
+
|
|
17
|
+
function getHomeEnvPaths() {
|
|
18
|
+
const homeDir = getHappyStacksHomeDir();
|
|
19
|
+
return {
|
|
20
|
+
homeEnv: join(homeDir, '.env'),
|
|
21
|
+
homeLocal: join(homeDir, 'env.local'),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function main() {
|
|
26
|
+
const argv = process.argv.slice(2);
|
|
27
|
+
const { flags } = parseArgs(argv);
|
|
28
|
+
const json = wantsJson(argv, { flags });
|
|
29
|
+
if (wantsHelp(argv, { flags }) || argv.includes('help')) {
|
|
30
|
+
printResult({
|
|
31
|
+
json,
|
|
32
|
+
data: { flags: ['--json'], commands: ['where'] },
|
|
33
|
+
text: ['[where] usage:', ' hstack where [--json]'].join('\n'),
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const rootDir = getRootDir(import.meta.url);
|
|
39
|
+
const homeDir = getHappyStacksHomeDir();
|
|
40
|
+
const canonicalHomeDir = getCanonicalHomeDir();
|
|
41
|
+
const canonicalEnv = getCanonicalHomeEnvPath();
|
|
42
|
+
const sandboxDir = getSandboxDir();
|
|
43
|
+
const runtimeDir = getRuntimeDir();
|
|
44
|
+
const workspaceDir = getWorkspaceDir(rootDir);
|
|
45
|
+
const repoDir = getRepoDir(rootDir);
|
|
46
|
+
const worktreeCategoryDirs = Object.fromEntries(
|
|
47
|
+
WORKTREE_CATEGORIES.map((c) => [c, getWorktreeCategoryRoot(rootDir, c, process.env)])
|
|
48
|
+
);
|
|
49
|
+
const mainDir = getRepoDir(rootDir, { ...process.env, HAPPIER_STACK_REPO_DIR: '' });
|
|
50
|
+
const devDir = getDevRepoDir(rootDir, process.env);
|
|
51
|
+
|
|
52
|
+
const stackName = getStackName();
|
|
53
|
+
const stackLabel = getStackLabel(stackName);
|
|
54
|
+
const resolvedMainEnv = resolveStackEnvPath('main');
|
|
55
|
+
const resolvedActiveEnv = process.env.HAPPIER_STACK_ENV_FILE?.trim()
|
|
56
|
+
? { envPath: expandHome(process.env.HAPPIER_STACK_ENV_FILE.trim()) }
|
|
57
|
+
: null;
|
|
58
|
+
|
|
59
|
+
const { homeEnv, homeLocal } = getHomeEnvPaths();
|
|
60
|
+
const updateCachePath = join(homeDir, 'cache', 'update.json');
|
|
61
|
+
|
|
62
|
+
const packageNames = ['happier-ui', 'happier-cli', 'happier-server'];
|
|
63
|
+
const packageDirs = Object.fromEntries(packageNames.map((name) => [name, getComponentDir(rootDir, name)]));
|
|
64
|
+
|
|
65
|
+
printResult({
|
|
66
|
+
json,
|
|
67
|
+
data: {
|
|
68
|
+
ok: true,
|
|
69
|
+
rootDir,
|
|
70
|
+
sandbox: sandboxDir ? { enabled: true, dir: sandboxDir } : { enabled: false },
|
|
71
|
+
homeDir,
|
|
72
|
+
canonicalHomeDir,
|
|
73
|
+
runtimeDir,
|
|
74
|
+
workspaceDir,
|
|
75
|
+
repoDir,
|
|
76
|
+
checkouts: { main: mainDir, dev: devDir },
|
|
77
|
+
worktrees: worktreeCategoryDirs,
|
|
78
|
+
stack: { name: stackName, label: stackLabel },
|
|
79
|
+
envFiles: {
|
|
80
|
+
canonical: { path: canonicalEnv, exists: existsSync(canonicalEnv) },
|
|
81
|
+
homeEnv: { path: homeEnv, exists: existsSync(homeEnv) },
|
|
82
|
+
homeLocal: { path: homeLocal, exists: existsSync(homeLocal) },
|
|
83
|
+
active: resolvedActiveEnv ? { path: resolvedActiveEnv.envPath, exists: existsSync(resolvedActiveEnv.envPath) } : null,
|
|
84
|
+
main: { path: resolvedMainEnv.envPath, exists: existsSync(resolvedMainEnv.envPath) },
|
|
85
|
+
},
|
|
86
|
+
packages: packageDirs,
|
|
87
|
+
update: {
|
|
88
|
+
enabled: (process.env.HAPPIER_STACK_UPDATE_CHECK ?? '1') !== '0',
|
|
89
|
+
cachePath: updateCachePath,
|
|
90
|
+
cacheExists: existsSync(updateCachePath),
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
text: [
|
|
94
|
+
'',
|
|
95
|
+
banner('where', { subtitle: 'Resolved paths and env sources.' }),
|
|
96
|
+
'',
|
|
97
|
+
sectionTitle('Paths'),
|
|
98
|
+
bullets([
|
|
99
|
+
kv('root:', rootDir),
|
|
100
|
+
sandboxDir ? kv('sandbox:', sandboxDir) : null,
|
|
101
|
+
kv('canonical:', canonicalHomeDir),
|
|
102
|
+
kv('home:', homeDir),
|
|
103
|
+
kv('runtime:', runtimeDir),
|
|
104
|
+
kv('workspace:', workspaceDir),
|
|
105
|
+
kv('repo:', repoDir),
|
|
106
|
+
kv('main:', mainDir),
|
|
107
|
+
kv('dev:', devDir),
|
|
108
|
+
kv('pr:', worktreeCategoryDirs.pr),
|
|
109
|
+
kv('local:', worktreeCategoryDirs.local),
|
|
110
|
+
kv('tmp:', worktreeCategoryDirs.tmp),
|
|
111
|
+
].filter(Boolean)),
|
|
112
|
+
'',
|
|
113
|
+
sectionTitle('Active stack'),
|
|
114
|
+
bullets([kv('stack:', `${cyan(stackName)} (${stackLabel})`)]),
|
|
115
|
+
'',
|
|
116
|
+
sectionTitle('Env files'),
|
|
117
|
+
bullets([
|
|
118
|
+
kv('canonical pointer:', existsSync(canonicalEnv) ? canonicalEnv : `${canonicalEnv} ${dim('(missing)')}`),
|
|
119
|
+
kv('home defaults:', existsSync(homeEnv) ? homeEnv : `${homeEnv} ${dim('(missing)')}`),
|
|
120
|
+
kv('home overrides:', existsSync(homeLocal) ? homeLocal : `${homeLocal} ${dim('(missing)')}`),
|
|
121
|
+
kv('active:', resolvedActiveEnv?.envPath ? resolvedActiveEnv.envPath : dim('(none)')),
|
|
122
|
+
kv('main:', resolvedMainEnv.envPath),
|
|
123
|
+
]),
|
|
124
|
+
'',
|
|
125
|
+
sectionTitle('Repo packages'),
|
|
126
|
+
bullets(packageNames.map((n) => kv(n + ':', packageDirs[n]))),
|
|
127
|
+
'',
|
|
128
|
+
sectionTitle('Update'),
|
|
129
|
+
bullets([kv('cache:', updateCachePath)]),
|
|
130
|
+
'',
|
|
131
|
+
].join('\n'),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
main().catch((err) => {
|
|
136
|
+
console.error('[where] failed:', err);
|
|
137
|
+
process.exit(1);
|
|
138
|
+
});
|