Closes #146, #147, #148. Parallel plan isolation (#148, @shawnli1874): init-session.sh slug mode creates .planning/YYYY-MM-DD-<slug>/ for each task. set-active-plan.sh/.ps1 switch the active plan pointer. resolve-plan-dir.sh/.ps1 provide the resolution chain ($PLAN_ID env, .active_plan file, newest plan dir, legacy fallback). All four Codex hooks route through the resolver. resolve_latest_dir now requires task_plan.md to be present, preventing system dirs like sessions/ from being selected as plan dirs. short_uuid() probes each Python candidate before trusting command -v, fixing silent failure on Windows Store aliases. Codex session isolation (#146, @githubYiheng): sessions attach to a plan by creating .planning/sessions/<session_id>.attached. user-prompt-submit.sh, pre_tool_use.py, stop.py, and post_tool_use.py all gate on session attachment before injecting context or blocking. Legacy mode preserved when .planning/sessions/ does not exist. Hermes integration notes (#147, @09ashishkapoor): docs/hermes.md gains an Integration Notes section covering current support level, what is not full parity with hook-native platforms, recommended integration pattern, and a tradeoffs table. 34 new tests across five files. Version bumped to 2.36.0 across 14 SKILL.md variants, plugin.json, marketplace.json, and CITATION.cff.
77 lines
2.1 KiB
Bash
Executable File
77 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
# planning-with-files: resolve active plan directory.
|
|
#
|
|
# Resolution order:
|
|
# 1. $PLAN_ID env var → ./.planning/$PLAN_ID/ if exists
|
|
# 2. ./.planning/.active_plan content → matching dir if exists
|
|
# 3. Newest ./.planning/<dir>/ by mtime
|
|
# 4. Otherwise empty stdout (caller falls back to legacy ./task_plan.md)
|
|
#
|
|
# Always exits 0. Never errors out the agent loop.
|
|
#
|
|
# Usage:
|
|
# PLAN_DIR="$(sh scripts/resolve-plan-dir.sh)"
|
|
# PLAN_FILE="${PLAN_DIR:+$PLAN_DIR/}task_plan.md"
|
|
|
|
set -u
|
|
|
|
PLAN_ROOT="${1:-${PWD}/.planning}"
|
|
ACTIVE_FILE="${PLAN_ROOT}/.active_plan"
|
|
|
|
resolve_from_env() {
|
|
plan_id="${PLAN_ID:-}"
|
|
[ -z "${plan_id}" ] && return 1
|
|
candidate="${PLAN_ROOT}/${plan_id}"
|
|
if [ -d "${candidate}" ]; then
|
|
printf "%s\n" "${candidate}"
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
resolve_from_active_file() {
|
|
[ -f "${ACTIVE_FILE}" ] || return 1
|
|
plan_id="$(tr -d '\r\n' < "${ACTIVE_FILE}")"
|
|
[ -z "${plan_id}" ] && return 1
|
|
candidate="${PLAN_ROOT}/${plan_id}"
|
|
if [ -d "${candidate}" ]; then
|
|
printf "%s\n" "${candidate}"
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
resolve_latest_dir() {
|
|
[ -d "${PLAN_ROOT}" ] || return 1
|
|
# Portable newest-mtime selector. Avoid `ls -t` BSD/GNU drift.
|
|
# Only consider dirs that contain task_plan.md — skips system dirs like sessions/.
|
|
latest=""
|
|
latest_mtime=0
|
|
for entry in "${PLAN_ROOT}"/*/; do
|
|
[ -d "${entry}" ] || continue
|
|
# Strip trailing slash
|
|
clean="${entry%/}"
|
|
# Skip hidden dirs
|
|
case "$(basename "${clean}")" in
|
|
.*) continue ;;
|
|
esac
|
|
# Skip dirs that are not plan dirs
|
|
[ -f "${clean}/task_plan.md" ] || continue
|
|
mtime="$(date -r "${clean}" +%s 2>/dev/null || stat -c '%Y' "${clean}" 2>/dev/null || echo 0)"
|
|
if [ "${mtime}" -gt "${latest_mtime}" ] 2>/dev/null; then
|
|
latest_mtime="${mtime}"
|
|
latest="${clean}"
|
|
fi
|
|
done
|
|
if [ -n "${latest}" ]; then
|
|
printf "%s\n" "${latest}"
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
if resolve_from_env; then exit 0; fi
|
|
if resolve_from_active_file; then exit 0; fi
|
|
if resolve_latest_dir; then exit 0; fi
|
|
exit 0
|