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
9 changes: 7 additions & 2 deletions skills/worklog/bin/preamble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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".
Expand Down
2 changes: 1 addition & 1 deletion skills/worklog/modes/sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 28 additions & 1 deletion skills/worklog/tests/init/test_light_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Loading