diff --git a/skills/worklog/bin/preamble.sh b/skills/worklog/bin/preamble.sh index 2634f60..5e72dfd 100755 --- a/skills/worklog/bin/preamble.sh +++ b/skills/worklog/bin/preamble.sh @@ -22,9 +22,10 @@ set -euo pipefail mode="${1:---full}" case "$mode" in - --minimal|--full) ;; - *) echo "usage: $0 [--minimal|--full]" >&2; exit 2 ;; + --minimal|--light|--full) ;; + *) echo "usage: $0 [--minimal|--light|--full]" >&2; exit 2 ;; esac +[[ "$mode" == "--light" ]] && mode="--minimal" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=_lib.sh @@ -87,6 +88,10 @@ else printf 'PULL=skip (minimal)\n' fi +# Re-compute counts after pull so roster-health comparison uses current state. +active_total="$(find people -path '*/active/*.md' -type f 2>/dev/null | wc -l | tr -d '[:space:]')" +active_namespace="$(find "people/$LDAP/active" -maxdepth 1 -name '*.md' -type f 2>/dev/null | wc -l | tr -d '[:space:]')" + # Roster (fresh kernels JSON or a read-only raw Markdown fallback). The health # line is intentionally separate so fresh agents can tell degraded cache state # from "no work". diff --git a/skills/worklog/modes/sync.md b/skills/worklog/modes/sync.md index 82026ee..7c13929 100644 --- a/skills/worklog/modes/sync.md +++ b/skills/worklog/modes/sync.md @@ -4,7 +4,7 @@ One command handles every save path. Pick the first applicable in order; stop th ## Non-interactive guard -If `$CLAUDE_HOOK` is set or stdin is not a TTY, skip conversation-WIP detection (it requires judgment). Fall through to autosave only. +If `$CLAUDE_CODE_SESSION_ID`, `$CODEX_SESSION_ID`, `$CURSOR_SESSION_ID`, or `$OPENAI_SESSION_ID` is set — or stdin is not a TTY — skip conversation-WIP detection (it requires judgment). Fall through to autosave only. ## Precedence diff --git a/skills/worklog/tests/init/test_light_init.sh b/skills/worklog/tests/init/test_light_init.sh index 7760e94..95b376b 100755 --- a/skills/worklog/tests/init/test_light_init.sh +++ b/skills/worklog/tests/init/test_light_init.sh @@ -61,4 +61,31 @@ after_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || [[ "$after_kernel_mtime" == "$before_kernel_mtime" ]] [[ "$after_pull_mtime" == "$before_pull_mtime" ]] -echo "ok: default/light init routes to non-mutating minimal preamble" +echo "ok: --minimal accepted (non-mutating)" + +# Restore fixture for --light test +git -C "$TMP" checkout -- . +printf '\ndirty\n' >> "$TMP/people/tester/active/light-init.md" +before_status="$(git -C "$TMP" status --porcelain)" +before_kernel_mtime="$(stat -c %Y "$TMP/.cache/compact-kernels.json" 2>/dev/null || stat -f %m "$TMP/.cache/compact-kernels.json")" +before_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || stat -f %m "$TMP/.cache/preamble-pull-stamp")" + +WORKLOG_REPO="$TMP" WORKLOG_LDAP=tester \ + "$WORKLOG_BIN/preamble.sh" --light >/dev/null + +after_status="$(git -C "$TMP" status --porcelain)" +after_kernel_mtime="$(stat -c %Y "$TMP/.cache/compact-kernels.json" 2>/dev/null || stat -f %m "$TMP/.cache/compact-kernels.json")" +after_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || stat -f %m "$TMP/.cache/preamble-pull-stamp")" + +[[ "$after_status" == "$before_status" ]] +[[ "$after_kernel_mtime" == "$before_kernel_mtime" ]] +[[ "$after_pull_mtime" == "$before_pull_mtime" ]] + +echo "ok: --light accepted and behaves identically to --minimal" + +# Adversarial: unknown flags must be rejected. +if "$WORKLOG_BIN/preamble.sh" --bogus >/dev/null 2>&1; then + echo "FAIL: --bogus should have been rejected" + exit 1 +fi +echo "ok: --bogus rejected (exit != 0)"