Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.2] - 2026-10-04

### Fixed
- In Claude Code, every session end showed `SessionEnd hook [steplock] failed: Hook JSON output validation failed`. polyhook labeled Claude Code's `SessionEnd` (and `SessionStart`) as Gemini CLI and answered `{"decision":"allow"}`. steplock now requires polyhook 0.1.12, which detects them as Claude Code and answers `{}`

## [0.2.1] - 2026-09-29

### Fixed
Expand Down
12 changes: 6 additions & 6 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "steplock"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
rust-version = "1.88"
description = "Stateful quality gate logic for steplock"
Expand Down Expand Up @@ -54,7 +54,6 @@ use_self = "deny"
ref_option_ref = "deny"
cast_lossless = "deny"
checked_conversions = "deny"
from_iter_instead_of_collect = "deny"
doc_markdown = "deny"
str_to_string = "deny"
multiple_inherent_impl = "deny"
Expand Down Expand Up @@ -85,6 +84,7 @@ unwrap_used = "deny"
wildcard_imports = "deny"
enum_glob_use = "deny"
single_match_else = "deny"
unnecessary_wraps = "deny"
manual_let_else = "deny"
items_after_statements = "deny"
needless_pass_by_value = "deny"
Expand All @@ -95,7 +95,7 @@ cel-interpreter = "0.10"
clap = { version = "4.5", features = ["derive"] }
chrono = { version = "0.4", features = ["serde"] }
dirs = "6"
polyhook = "0.1.5"
polyhook = "0.1.12"
same-file = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
34 changes: 14 additions & 20 deletions core/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,8 @@ fn main() {
Some(CliCommand::Validate) => {
let dir = env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
let root = find_repo_root_from(&dir).unwrap_or(dir);
match run_validate(&root, global_steplock_dir().as_deref()) {
Ok(true) => {}
Ok(false) => process::exit(1),
Err(e) => {
eprintln!("steplock: validate failed: {e}");
process::exit(1);
}
if !run_validate(&root, global_steplock_dir().as_deref()) {
process::exit(1);
}
}
Some(CliCommand::Clean { global: false }) => {
Expand All @@ -102,19 +97,18 @@ fn exit_on_error(command: &str, result: io::Result<()>) {
}

/// Validate all checklists in `.steplock/checklists/` and in the global steplock directory.
/// Returns `Ok(true)` if all valid, `Ok(false)` if any checklist failed validation (errors
/// already printed), or `Err` on I/O.
fn run_validate(repo_root: &Path, global_dir: Option<&Path>) -> io::Result<bool> {
let project_ok = validate_dir(&repo_root.join(".steplock").join("checklists"), "")?;
let global_ok = match global_dir {
Some(global) => validate_dir(&global.join("checklists"), "global")?,
None => true,
};
Ok(project_ok && global_ok)
/// Returns `true` if all valid, `false` if any checklist failed validation (errors already
/// printed). Both directories are always checked, so every error is reported.
fn run_validate(repo_root: &Path, global_dir: Option<&Path>) -> bool {
let project_ok = validate_dir(&repo_root.join(".steplock").join("checklists"), "");
let global_ok =
global_dir.is_none_or(|global| validate_dir(&global.join("checklists"), "global"));
project_ok && global_ok
}

/// Validate one `checklists/` directory. `scope` names it in messages (`""` or `"global"`).
fn validate_dir(checklists_dir: &Path, scope: &str) -> io::Result<bool> {
/// Returns `false` if any checklist failed validation (errors already printed).
fn validate_dir(checklists_dir: &Path, scope: &str) -> bool {
let shown = checklists_dir.display();
let (words, label_prefix) = if scope.is_empty() {
(String::new(), String::new())
Expand All @@ -123,18 +117,18 @@ fn validate_dir(checklists_dir: &Path, scope: &str) -> io::Result<bool> {
};
if !checklists_dir.exists() {
println!("steplock: no {words}checklists found at {shown}");
return Ok(true);
return true;
}

let errors = steplock::validate_checklists(checklists_dir);
if errors.is_empty() {
println!("steplock: all {words}checklists valid ({shown})");
Ok(true)
true
} else {
for (label, err) in &errors {
eprintln!("steplock: [{label_prefix}{label}] error: {err}");
}
Ok(false)
false
}
}

Expand Down
16 changes: 8 additions & 8 deletions core/src/bin/main_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,21 @@ fn clean_leaves_sessions_dir_intact() {
#[test]
fn validate_returns_true_when_no_checklists_dir() {
let tmp = TempDir::new().unwrap();
assert!(run_validate(tmp.path(), None).unwrap());
assert!(run_validate(tmp.path(), None));
}

#[test]
fn validate_returns_true_when_checklists_empty() {
let tmp = TempDir::new().unwrap();
fs::create_dir_all(tmp.path().join(".steplock/checklists")).unwrap();
assert!(run_validate(tmp.path(), None).unwrap());
assert!(run_validate(tmp.path(), None));
}

#[test]
fn validate_returns_true_for_valid_checklist() {
let tmp = TempDir::new().unwrap();
setup_checklist(tmp.path());
assert!(run_validate(tmp.path(), None).unwrap());
assert!(run_validate(tmp.path(), None));
}

#[test]
Expand All @@ -233,7 +233,7 @@ fn validate_returns_false_when_config_toml_missing() {
"stateDiagram-v2\n [*] --> s\n s --> [*]\n s: Step\n",
)
.unwrap();
assert!(!run_validate(tmp.path(), None).unwrap());
assert!(!run_validate(tmp.path(), None));
}

#[test]
Expand All @@ -246,7 +246,7 @@ fn validate_returns_false_when_flow_mmd_missing() {
"on_event = \"tool:before\"\nreset = \"session\"\n",
)
.unwrap();
assert!(!run_validate(tmp.path(), None).unwrap());
assert!(!run_validate(tmp.path(), None));
}

#[test]
Expand All @@ -260,7 +260,7 @@ fn validate_returns_false_for_invalid_config_toml() {
"stateDiagram-v2\n [*] --> s\n s --> [*]\n s: Step\n",
)
.unwrap();
assert!(!run_validate(tmp.path(), None).unwrap());
assert!(!run_validate(tmp.path(), None));
}

#[test]
Expand All @@ -274,7 +274,7 @@ fn validate_returns_false_for_invalid_flow_mmd() {
)
.unwrap();
fs::write(cl_dir.join("flow.mmd"), "stateDiagram-v2\n a --> b\n").unwrap();
assert!(!run_validate(tmp.path(), None).unwrap());
assert!(!run_validate(tmp.path(), None));
}

#[test]
Expand All @@ -289,7 +289,7 @@ fn validate_continues_checking_all_checklists_after_failure() {
"stateDiagram-v2\n [*] --> s\n s --> [*]\n s: Step\n",
)
.unwrap();
assert!(!run_validate(tmp.path(), None).unwrap());
assert!(!run_validate(tmp.path(), None));
}

fn parse(args: &[&str]) -> Cli {
Expand Down
Loading