Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 6 additions & 30 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ fn prepare_hook_paths() -> Result<(PathBuf, PathBuf)> {
}

/// Write hook file if missing or outdated, return true if changed
#[cfg(unix)]
fn ensure_hook_installed(hook_path: &Path, verbose: u8) -> Result<bool> {
let changed = if hook_path.exists() {
let existing = fs::read_to_string(hook_path)
Expand Down Expand Up @@ -326,10 +325,12 @@ fn ensure_hook_installed(hook_path: &Path, verbose: u8) -> Result<bool> {
true
};

// Set executable permissions
use std::os::unix::fs::PermissionsExt;
fs::set_permissions(hook_path, fs::Permissions::from_mode(0o755))
.with_context(|| format!("Failed to set hook permissions: {}", hook_path.display()))?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
fs::set_permissions(hook_path, fs::Permissions::from_mode(0o755))
.with_context(|| format!("Failed to set hook permissions: {}", hook_path.display()))?;
}

// Store SHA-256 hash for runtime integrity verification.
// Always store (idempotent) to ensure baseline exists even for
Expand Down Expand Up @@ -862,20 +863,6 @@ fn hook_already_present(root: &serde_json::Value, hook_command: &str) -> bool {
}

/// Default mode: hook + slim RTK.md + @RTK.md reference
#[cfg(not(unix))]
fn run_default_mode(
_global: bool,
_patch_mode: PatchMode,
_verbose: u8,
_install_opencode: bool,
) -> Result<()> {
eprintln!("[warn] Hook-based mode requires Unix (macOS/Linux).");
eprintln!(" Windows: use --claude-md mode for full injection.");
eprintln!(" Falling back to --claude-md mode.");
run_claude_md_mode(_global, _verbose, _install_opencode)
}

#[cfg(unix)]
fn run_default_mode(
global: bool,
patch_mode: PatchMode,
Expand Down Expand Up @@ -1009,17 +996,6 @@ fn generate_global_filters_template(verbose: u8) -> Result<()> {
}

/// Hook-only mode: just the hook, no RTK.md
#[cfg(not(unix))]
fn run_hook_only_mode(
_global: bool,
_patch_mode: PatchMode,
_verbose: u8,
_install_opencode: bool,
) -> Result<()> {
anyhow::bail!("Hook install requires Unix (macOS/Linux). Use WSL or --claude-md mode.")
}

#[cfg(unix)]
fn run_hook_only_mode(
global: bool,
patch_mode: PatchMode,
Expand Down