pub fn generate_pre_commit_hook(config: &HookConfig) -> Result<String> {
let script = match &config.project_type {
TemplateType::Agent { .. } => generate_pforge_hook(config),
TemplateType::Wasm { .. } => generate_wasm_hook(config),
_ => return Err(ScaffoldError::UnsupportedProjectType),
};
Ok(script)
}
fn generate_pforge_hook(_config: &HookConfig) -> String {
r#"#!/bin/bash
# Pre-commit hook for pforge project
# Generated by PMAT ScaffoldEngine
set -e
echo "Running pre-commit quality gates..."
# Clippy (strict mode)
echo "→ Running clippy..."
cargo clippy --all-targets --all-features -- -D warnings
# Tests
echo "→ Running tests..."
cargo test
echo "✓ All quality gates passed!"
exit 0
"#
.to_string()
}
fn generate_wasm_hook(_config: &HookConfig) -> String {
r#"#!/bin/bash
# Pre-commit hook for WASM project
# Generated by PMAT ScaffoldEngine
set -e
echo "Running pre-commit quality gates..."
# Clippy (strict mode)
echo "→ Running clippy..."
cargo clippy --all-targets --all-features -- -D warnings
# Tests
echo "→ Running tests..."
cargo test
# WASM build verification
echo "→ Verifying WASM build..."
cargo build --target wasm32-unknown-unknown --release
echo "✓ All quality gates passed!"
exit 0
"#
.to_string()
}
pub fn generate_post_commit_hook() -> String {
r#"#!/bin/bash
# Post-commit hook for roadmap updates
# Generated by PMAT Maintenance Engine
# Only run if this is a ticket commit
if ! git log -1 --pretty=%B | grep -q "TICKET-PMAT-"; then
exit 0
fi
# Run roadmap updater
if command -v pmat &> /dev/null; then
pmat maintain update-roadmap --from-commit HEAD 2>/dev/null || true
fi
exit 0
"#
.to_string()
}