Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f67e2bb729 | ||
|
|
a718f05689 | ||
|
|
3cbb7dcc4b | ||
|
|
e8ad1534ed | ||
|
|
5046267994 | ||
|
|
ecaf63f689 | ||
|
|
0d21b6c4aa | ||
|
|
f118ab5025 | ||
|
|
ec2ec0a796 | ||
|
|
16bf0a5ac0 |
@@ -28,7 +28,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\"; [ -f \"$SH\" ] || SH=$(ls \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\" 2>/dev/null | head -1); [ -n \"$SH\" ] && [ -f \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
---
|
||||
|
||||
# Planning with Files
|
||||
@@ -40,7 +40,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
**Before continuing**, resolve the plan this task owns:
|
||||
|
||||
1. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the task's `PLAN_ID` and `PWF_PLAN_ROOT`. Read `task_plan.md`, `progress.md`, and `findings.md` from that one selected directory. A root `task_plan.md` must not override a selected `.planning/<id>/` plan.
|
||||
2. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, stop plan recovery and correct the pin. Do not fall back to another task. Use the legacy project-root files only when no selector or named plan applies.
|
||||
2. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, stop plan recovery and correct the pin. Do not fall back to another task. Use the legacy project-root files only when no selector or named plan applies.
|
||||
3. Run `git diff --stat` to see code changes that may not yet be recorded in the planning files.
|
||||
|
||||
All planning filenames below refer to this selected directory, even when the shell runs elsewhere. For parallel tasks, pin each host before starting it or use separate worktrees. A worker joining an existing task uses its assigned plan; it must not create or overwrite a competing root plan.
|
||||
@@ -221,7 +221,7 @@ Helper scripts for automation:
|
||||
|
||||
- `scripts/init-session.sh` — Initialize planning files. With a name arg, creates an isolated plan under `.planning/YYYY-MM-DD-<slug>/` for parallel task workflows. Without args, writes `task_plan.md` at project root (legacy mode, backward-compatible).
|
||||
- `scripts/set-active-plan.sh` — Switch the active plan pointer (`.planning/.active_plan`). Run with a plan ID to switch; run without args to show which plan is current.
|
||||
- `scripts/resolve-plan-dir.sh` — Resolve the active plan directory. A set `$PLAN_ID` is a binding: it resolves or resolution stops, never another plan (issue #237). With no `$PLAN_ID`, checks `.planning/.active_plan`, then newest plan dir by mtime, then falls back to project root (legacy). Used internally by hooks.
|
||||
- `scripts/resolve-plan-dir.sh` — Resolve the active plan directory. A set `$PLAN_ID` is a binding: it resolves or resolution stops, never another plan (issue #237). With no `$PLAN_ID`, multiple named plans refuse selection. A single named plan may use `.planning/.active_plan` or discovery by mtime; otherwise resolution falls back to the project root (legacy). Used internally by hooks.
|
||||
- `scripts/check-complete.sh` — Verify all phases in the active plan are complete.
|
||||
- `scripts/session-catchup.py`: Explicit same-project session-record aggregation or bounded replay (`--metadata` / `--replay`); bare invocation does not access host history.
|
||||
- `scripts/attest-plan.sh` (and `.ps1`) — Lock the current `task_plan.md` content with a SHA-256 attestation (v2.37.0). Hooks then refuse to inject plan content if the file diverges from the attested hash. Use `--show` to print the stored hash, `--clear` to remove the attestation. See `/plan-attest` command.
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"name": "planning-with-files",
|
||||
"source": "./",
|
||||
"description": "Persistent project planning files with lifecycle hooks that inject selected plan context. Automatic recovery uses project files only. Explicit catchup modes may read same-project local session records to emit aggregate counts or bounded nonce-framed excerpts. Optional gated mode can request continuation on capable hosts and never runs commands declared in Markdown. No network upload path. Installs across 60+ agents.",
|
||||
"version": "3.16.1"
|
||||
"version": "3.17.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "planning-with-files",
|
||||
"version": "3.16.1",
|
||||
"version": "3.17.2",
|
||||
"description": "Persistent project planning files with lifecycle hooks that inject selected plan context. Automatic recovery uses project files only. Explicit catchup modes may read same-project local session records to emit aggregate counts or bounded nonce-framed excerpts. Optional gated mode can request continuation on capable hosts and never runs commands declared in Markdown. No network upload path. Works across 60+ agents and includes Arabic, German, Spanish, Simplified Chinese, and Traditional Chinese.",
|
||||
"author": {
|
||||
"name": "OthmanAdi",
|
||||
|
||||
@@ -36,7 +36,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"\"; for c in \"${PWF_SCRIPT_DIR}/skill-hook.sh\" \"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\" \"${CODEBUDDY_PLUGIN_ROOT}/scripts/skill-hook.sh\" \"$HOME/.codebuddy/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\"; do [ -f \"$c\" ] && { SH=\"$c\"; break; }; done; [ -n \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
|
||||
---
|
||||
|
||||
@@ -46,7 +46,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
|
||||
## FIRST: Restore Project State
|
||||
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
|
||||
```bash
|
||||
# Linux/macOS — auto-detects skill directory (plugin env or default install path)
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "planning-with-files",
|
||||
"version": "3.16.1",
|
||||
"version": "3.17.2",
|
||||
"description": "Persistent project planning for Codex. Opt-in lifecycle hooks inject selected plan context; automatic recovery uses project files only. Explicit catchup modes may read same-project local session records to emit aggregate counts or bounded nonce-framed excerpts. Optional gated mode can request continuation on capable hosts and never runs Markdown-declared commands. No network upload path.",
|
||||
"author": {
|
||||
"name": "OthmanAdi",
|
||||
@@ -8,6 +8,7 @@
|
||||
},
|
||||
"repository": "https://github.com/OthmanAdi/planning-with-files",
|
||||
"license": "MIT",
|
||||
"commands": [],
|
||||
"skills": "./.agents/skills/",
|
||||
"hooks": "./hooks/codex-hooks.json"
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ HOOK_DIR = Path(__file__).resolve().parent
|
||||
_SAFE_LEGACY_SESSION_ID = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]{0,127}\Z")
|
||||
_PLAN_SLUG = re.compile(r"[A-Za-z0-9_][A-Za-z0-9._-]*\Z")
|
||||
SESSION_PLAN_BINDING_NOTICE = (
|
||||
"[planning-with-files] Multiple plans are available while session isolation "
|
||||
"is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
"[planning-with-files] Multiple plans are available. "
|
||||
"Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
)
|
||||
_DARWIN_SYSTEM_ALIASES = {
|
||||
Path("/var"): Path("/private/var"),
|
||||
@@ -223,23 +223,21 @@ def session_plan_requires_binding(root: Path) -> bool:
|
||||
"""Require PLAN_ID when an attached session can resolve multiple plans.
|
||||
|
||||
Session sentinels admit a session to planning context. They do not select a
|
||||
plan. Once isolation is armed, an unbound session may use legacy resolution
|
||||
only when the effective root has at most one live plan candidate.
|
||||
plan. Multiple named plans always require a pin. With isolation armed,
|
||||
a legacy root plan also counts as a competing candidate.
|
||||
"""
|
||||
if os.environ.get("PLAN_ID", ""):
|
||||
return False
|
||||
|
||||
sessions_dir = root / ".planning" / "sessions"
|
||||
try:
|
||||
sessions_info = sessions_dir.lstat()
|
||||
if _is_reparse_or_link(sessions_dir) or not stat.S_ISDIR(sessions_info.st_mode):
|
||||
return False
|
||||
except (FileNotFoundError, OSError, RuntimeError):
|
||||
armed = sessions_dir.exists() or sessions_dir.is_symlink()
|
||||
planning_dir = root / ".planning"
|
||||
if not planning_dir.exists():
|
||||
return False
|
||||
|
||||
candidates = 0
|
||||
try:
|
||||
if (root / "task_plan.md").is_file():
|
||||
if armed and (root / "task_plan.md").is_file():
|
||||
candidates += 1
|
||||
planning_dir = root / ".planning"
|
||||
for child in planning_dir.iterdir():
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
HOOK_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
|
||||
PLAN_DIR="$(sh "${HOOK_DIR}/resolve-plan-dir.sh" 2>/dev/null)"
|
||||
if [ -z "$PLAN_DIR" ] && [ "$(sh "${HOOK_DIR}/resolve-plan-dir.sh" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# An explicit PLAN_ID is a binding, not a hint (issue #237). When the shared
|
||||
# resolver rejected one it emits nothing, and the legacy-root fallback below
|
||||
# would answer for a plan the operator never named. Stay silent instead; the
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
HOOK_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
|
||||
PLAN_DIR="$(sh "${HOOK_DIR}/resolve-plan-dir.sh" 2>/dev/null)"
|
||||
if [ -z "$PLAN_DIR" ] && [ "$(sh "${HOOK_DIR}/resolve-plan-dir.sh" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# An explicit PLAN_ID is a binding, not a hint (issue #237). When the shared
|
||||
# resolver rejected one it emits nothing, and the legacy-root fallback below
|
||||
# would carry the wrong plan through compaction, which is the one moment the
|
||||
|
||||
@@ -10,6 +10,9 @@ fi
|
||||
|
||||
HOOK_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
|
||||
PLAN_DIR="$(sh "${HOOK_DIR}/resolve-plan-dir.sh" 2>/dev/null)"
|
||||
if [ -z "$PLAN_DIR" ] && [ "$(sh "${HOOK_DIR}/resolve-plan-dir.sh" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# An explicit PLAN_ID is a binding, not a hint (issue #237). When the shared
|
||||
# resolver rejected one it emits nothing, and the legacy-root fallback below
|
||||
# would recite a plan the operator never named on every tool call. Stay silent
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
HOOK_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
|
||||
PLAN_DIR="$(sh "${HOOK_DIR}/resolve-plan-dir.sh" 2>/dev/null)"
|
||||
if [ -z "$PLAN_DIR" ] && [ "$(sh "${HOOK_DIR}/resolve-plan-dir.sh" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
# An explicit PLAN_ID is a binding, not a hint (issue #237). When the shared
|
||||
# resolver rejected one it emits nothing, and the legacy-root fallback below
|
||||
# would decide whether this run may stop from a plan the operator never named.
|
||||
|
||||
@@ -76,6 +76,10 @@ fi
|
||||
# Resolve and confirm a contained plan before probing or executing any Python
|
||||
# candidate. No-plan hook fires remain shell-only and silent.
|
||||
PLAN_DIR="$(sh "${HOOK_DIR}/resolve-plan-dir.sh" 2>/dev/null)"
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "$PLAN_DIR" ] && [ "$(sh "${HOOK_DIR}/resolve-plan-dir.sh" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
PLAN_AMBIGUOUS=1
|
||||
fi
|
||||
if [ -n "$PLAN_DIR" ]; then
|
||||
PLAN_FILE="${PLAN_DIR}/task_plan.md"
|
||||
PROGRESS_FILE="${PLAN_DIR}/progress.md"
|
||||
@@ -92,7 +96,7 @@ else
|
||||
PLAN_FILE="${PLAN_PREFIX}task_plan.md"
|
||||
PROGRESS_FILE="${PLAN_PREFIX}progress.md"
|
||||
fi
|
||||
[ -f "$PLAN_FILE" ] || exit 0
|
||||
[ -f "$PLAN_FILE" ] || [ "$PLAN_AMBIGUOUS" = "1" ] || exit 0
|
||||
|
||||
# --- Re-arm the once-per-turn PostToolUse nudge (issue #239). ---
|
||||
# One user message is one turn, and this hook fires once per turn, so clearing
|
||||
@@ -113,7 +117,7 @@ elif [ -n "${HOME:-}" ]; then
|
||||
else
|
||||
TURN_ROOT="${TMPDIR:-/tmp}/pwf-turn"
|
||||
fi
|
||||
if [ -d "$TURN_ROOT" ]; then
|
||||
if [ "$PLAN_AMBIGUOUS" = "0" ] && [ -d "$TURN_ROOT" ]; then
|
||||
case "$TURN_PLAN_FILE" in
|
||||
/*|[A-Za-z]:*|\\\\*) TURN_KEY_SRC="$TURN_PLAN_FILE" ;;
|
||||
*) TURN_KEY_SRC="${PWD}/${TURN_PLAN_FILE}" ;;
|
||||
@@ -160,6 +164,11 @@ case "$PWF_SESSION_ADMISSION" in
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Plan-id safe-identifier check. Pure-sh case patterns; shared shape with
|
||||
# resolve-plan-dir.sh, needed below to decide whether PLAN_ID named the plan.
|
||||
slug_is_valid() {
|
||||
|
||||
@@ -36,7 +36,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"\"; for c in \"${PWF_SCRIPT_DIR}/skill-hook.sh\" \"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\" \"$HOME/.codex/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\"; do [ -f \"$c\" ] && { SH=\"$c\"; break; }; done; [ -n \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
|
||||
---
|
||||
|
||||
@@ -46,7 +46,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
|
||||
## FIRST: Restore Project State
|
||||
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
|
||||
```bash
|
||||
# Linux/macOS (auto-detects python3 or python)
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -36,7 +36,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"\"; for c in \"${PWF_SCRIPT_DIR}/skill-hook.sh\" \"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\" \"$HOME/.cursor/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\"; do [ -f \"$c\" ] && { SH=\"$c\"; break; }; done; [ -n \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
|
||||
---
|
||||
|
||||
@@ -46,7 +46,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
|
||||
## FIRST: Restore Project State
|
||||
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
|
||||
```bash
|
||||
# Linux/macOS (auto-detects python3 or python)
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -36,7 +36,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"\"; for c in \"${PWF_SCRIPT_DIR}/skill-hook.sh\" \"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\" \"$HOME/.factory/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\"; do [ -f \"$c\" ] && { SH=\"$c\"; break; }; done; [ -n \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
---
|
||||
|
||||
# Planning with Files
|
||||
@@ -45,7 +45,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
|
||||
## FIRST: Restore Project State
|
||||
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
|
||||
```bash
|
||||
$(command -v python3 || command -v python) .factory/skills/planning-with-files/scripts/session-catchup.py --metadata "$(pwd)"
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: planning-with-files
|
||||
description: "Persistent file-based planning for multi-step AI-agent work. Keeps task_plan.md, findings.md, and progress.md on disk; lifecycle hooks inject selected project planning context. Automatic recovery reads project planning files only. Explicit session-catchup.py --metadata reads same-project local agent session records and emits aggregate counts only; --replay may emit bounded nonce-framed excerpts. Optional gated mode can request continuation only when the host supports it and never runs commands declared in Markdown. The skill has no network upload path. Use for research or work needing 5+ tool calls."
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
hermes:
|
||||
tags: [planning, long-running-tasks, context-engineering, workflow]
|
||||
---
|
||||
|
||||
@@ -36,7 +36,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"\"; for c in \"${PWF_SCRIPT_DIR}/skill-hook.sh\" \"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\" \"$HOME/.mastracode/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\"; do [ -f \"$c\" ] && { SH=\"$c\"; break; }; done; [ -n \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
|
||||
---
|
||||
|
||||
@@ -46,7 +46,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
|
||||
## FIRST: Restore Project State
|
||||
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
|
||||
```bash
|
||||
# Linux/macOS
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -36,7 +36,7 @@ hooks:
|
||||
- type: command
|
||||
command: "SH=\"\"; for c in \"${PWF_SCRIPT_DIR}/skill-hook.sh\" \"${CLAUDE_SKILL_DIR}/scripts/skill-hook.sh\" \"$HOME/.config/opencode/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.opencode/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/skills/planning-with-files/scripts/skill-hook.sh\" \"$HOME/.claude/plugins/marketplaces/planning-with-files/scripts/skill-hook.sh\"; do [ -f \"$c\" ] && { SH=\"$c\"; break; }; done; [ -n \"$SH\" ] && sh \"$SH\" --event=precompact; exit 0"
|
||||
metadata:
|
||||
version: "3.16.1"
|
||||
version: "3.17.2"
|
||||
|
||||
---
|
||||
|
||||
@@ -46,7 +46,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
|
||||
## FIRST: Restore Project State
|
||||
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
**Before continuing**, resolve the plan this task owns. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the host's `PLAN_ID` and `PWF_PLAN_ROOT`, then read `task_plan.md`, `progress.md`, and `findings.md` from that selected directory. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, correct the pin and do not fall back to another task. Run `git diff --stat` for code changes not yet recorded there. All planning filenames below mean that selected directory. For parallel tasks, pin each host before it starts or use separate worktrees; a child process export does not change its host. One orchestrator owns a shared plan and summaries, while workers use assigned files or ledgers.
|
||||
|
||||
```bash
|
||||
# Linux/macOS (auto-detects python3 or python)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
# planning-with-files
|
||||
<div align="center">
|
||||
<img src="https://raw.githubusercontent.com/OthmanAdi/planning-with-files/master/media/v3-banner-1400.jpg" alt="planning-with-files: task_plan.md, findings.md, and progress.md as three stone tablets" width="100%">
|
||||
</div>
|
||||
|
||||
> **Your agent's context window dies. The plan does not.**
|
||||
<h1 align="center">Planning with Files</h1>
|
||||
|
||||
Persistent file-based planning for AI coding agents. The skill keeps `task_plan.md`, `findings.md` and `progress.md` on disk. After `/plan-execute`, Pi lifecycle hooks inject selected project planning context so the plan survives context loss, `/clear`, crashes and compaction. Automatic recovery reads project files only. Reading same-project local session records for aggregate counts or bounded replay requires an explicit catchup mode.
|
||||
<p align="center">
|
||||
<strong>The planning skill your agent cannot ignore.</strong><br>
|
||||
Your agent's context window dies. The plan does not.
|
||||
</p>
|
||||
|
||||
This is the npm distribution of [OthmanAdi/planning-with-files](https://github.com/OthmanAdi/planning-with-files), which installs across 60+ agents via the Agent Skills standard. The package ships:
|
||||
Persistent file-based planning for AI coding agents. Keep the plan, research and progress in your project so work can continue after context loss, `/clear`, crashes or compaction.
|
||||
|
||||
- the planning skill itself: `SKILL.md`, `scripts/` and `templates/`
|
||||
- a [Pi Coding Agent](https://pi.dev) extension providing Claude-style lifecycle automation
|
||||
| File | Purpose |
|
||||
| --- | --- |
|
||||
| `task_plan.md` | Goals, phases and decisions |
|
||||
| `findings.md` | Research and discoveries |
|
||||
| `progress.md` | Work completed, checks and next steps |
|
||||
|
||||
This is the npm distribution of [OthmanAdi/planning-with-files](https://github.com/OthmanAdi/planning-with-files), available across 60+ agents via the Agent Skills standard. It includes the planning skill, scripts and templates. Supported agent integrations add lifecycle hooks that bring selected planning context back into the session.
|
||||
|
||||
Automatic recovery reads project files only. Reading same-project local session records for aggregate counts or bounded replay requires an explicit catchup mode.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -19,19 +31,40 @@ npm install planning-with-files
|
||||
|
||||
Places the skill, scripts and templates under `node_modules/planning-with-files/`. Use this to pin an exact version into a project, or to copy `SKILL.md` and `scripts/` into your agent's skills directory yourself. It does not register hooks on its own.
|
||||
|
||||
### Pi Install
|
||||
### Agent integrations
|
||||
|
||||
Claude Code gets the full surface (skill, hooks, slash commands) through the plugin route, and 60+ other agents install in one line. See the [main README](https://github.com/OthmanAdi/planning-with-files#quick-install).
|
||||
|
||||
## Usage
|
||||
|
||||
Once the skill is installed for your agent, start with:
|
||||
|
||||
```text
|
||||
Use the planning-with-files skill to help me with this task.
|
||||
```
|
||||
|
||||
The workflow centers on three files in your project:
|
||||
|
||||
```text
|
||||
your-project/
|
||||
├── task_plan.md
|
||||
├── findings.md
|
||||
└── progress.md
|
||||
```
|
||||
|
||||
## Pi Coding Agent integration
|
||||
|
||||
The package also bundles a [Pi Coding Agent](https://pi.dev) extension for lifecycle automation and a planning status bar.
|
||||
|
||||
### Install in Pi
|
||||
|
||||
```bash
|
||||
pi install npm:planning-with-files
|
||||
```
|
||||
|
||||
Wires up the skill, the extension and the status bar automatically.
|
||||
Pi discovers the skill and extension from the installed package.
|
||||
|
||||
### Other agents
|
||||
|
||||
Claude Code gets the full surface (skill, hooks, slash commands) through the plugin route, and 60+ other agents install in one line. See the [main README](https://github.com/OthmanAdi/planning-with-files#quick-install).
|
||||
|
||||
### Manual Install
|
||||
For a local repository checkout:
|
||||
|
||||
```bash
|
||||
# From the planning-with-files repo root
|
||||
@@ -45,27 +78,13 @@ Or add to `.pi/settings.json`:
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
Pi discovers the skill and extension from the installed package.
|
||||
|
||||
Start with:
|
||||
|
||||
```text
|
||||
Use the planning-with-files skill to help me with this task.
|
||||
```
|
||||
|
||||
Or:
|
||||
You can also invoke the skill directly in Pi:
|
||||
|
||||
```text
|
||||
/skill:planning-with-files
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Hook Parity in Pi
|
||||
### Lifecycle hooks
|
||||
|
||||
The bundled extension maps Claude-style behavior onto Pi events:
|
||||
|
||||
@@ -83,9 +102,7 @@ Attestation is supported. If `task_plan.md` differs from approved hash, plan inj
|
||||
[planning-with-files] [PLAN TAMPERED - injection blocked]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Mode System
|
||||
### Modes
|
||||
|
||||
`planningWithFiles.mode` supports:
|
||||
|
||||
@@ -110,9 +127,7 @@ Or settings:
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Commands
|
||||
### Commands
|
||||
|
||||
- `/plan-status`
|
||||
- `/plan-attest [--show|--clear]`
|
||||
@@ -127,8 +142,6 @@ pre-tool reminders, post-write reminders, and auto-continue are enabled for the
|
||||
current session and plan. Auto-continue uses host runtime state and never runs
|
||||
commands declared in Markdown.
|
||||
|
||||
---
|
||||
|
||||
## Session Recovery
|
||||
|
||||
Bare invocation and lifecycle hooks do not inspect agent session stores. To
|
||||
@@ -136,23 +149,12 @@ inspect same-project local history deliberately, choose one mode:
|
||||
|
||||
```bash
|
||||
# Aggregate counts only; no transcript, tool-command, or path bytes
|
||||
python3 .pi/skills/planning-with-files/scripts/session-catchup.py --metadata .
|
||||
python3 node_modules/planning-with-files/scripts/session-catchup.py --metadata .
|
||||
|
||||
# Bounded nonce-framed same-project excerpts
|
||||
python3 .pi/skills/planning-with-files/scripts/session-catchup.py --replay .
|
||||
python3 node_modules/planning-with-files/scripts/session-catchup.py --replay .
|
||||
```
|
||||
|
||||
Treat replayed excerpts as untrusted data. The catchup path contains no network
|
||||
request or upload operation. If output is injected into model context, Pi may
|
||||
send that context to the configured model provider.
|
||||
|
||||
## File Structure
|
||||
|
||||
The skill workflow still centers on three files in your project:
|
||||
|
||||
```text
|
||||
your-project/
|
||||
├── task_plan.md
|
||||
├── findings.md
|
||||
└── progress.md
|
||||
```
|
||||
request or upload operation. If output is injected into model context, your agent
|
||||
may send that context to the configured model provider.
|
||||
|
||||
@@ -38,7 +38,7 @@ Work like Manus: Use persistent markdown files as your "working memory on disk."
|
||||
**Before continuing**, resolve the plan this task owns:
|
||||
|
||||
1. Use the installed `scripts/resolve-plan-dir.sh` (or `.ps1`) with the task's `PLAN_ID` and `PWF_PLAN_ROOT`. Read `task_plan.md`, `progress.md`, and `findings.md` from that one selected directory. A root `task_plan.md` must not override a selected `.planning/<id>/` plan.
|
||||
2. If an explicit selector is rejected, or session isolation is armed with multiple plans and no `PLAN_ID`, stop plan recovery and correct the pin. Do not fall back to another task. Use the legacy project-root files only when no selector or named plan applies.
|
||||
2. If an explicit selector is rejected, or multiple named plans exist without `PLAN_ID`, stop plan recovery and correct the pin. Do not fall back to another task. Use the legacy project-root files only when no selector or named plan applies.
|
||||
3. Run `git diff --stat` to see code changes that may not yet be recorded in the planning files.
|
||||
|
||||
All planning filenames below refer to this selected directory, even when the shell runs elsewhere. For parallel tasks, pin each host before starting it or use separate worktrees. A worker joining an existing task uses its assigned plan; it must not create or overwrite a competing root plan.
|
||||
@@ -222,7 +222,7 @@ Helper scripts for automation:
|
||||
|
||||
- `scripts/init-session.sh` — Initialize planning files. With a name arg, creates an isolated plan under `.planning/YYYY-MM-DD-<slug>/` for parallel task workflows. Without args, writes `task_plan.md` at project root (legacy mode, backward-compatible).
|
||||
- `scripts/set-active-plan.sh` — Switch the active plan pointer (`.planning/.active_plan`). Run with a plan ID to switch; run without args to show which plan is current.
|
||||
- `scripts/resolve-plan-dir.sh` — Resolve the active plan directory. A set `$PLAN_ID` is a binding: it resolves or resolution stops, never another plan (issue #237). With no `$PLAN_ID`, checks `.planning/.active_plan`, then newest plan dir by mtime, then falls back to project root (legacy). Used internally by hooks.
|
||||
- `scripts/resolve-plan-dir.sh` — Resolve the active plan directory. A set `$PLAN_ID` is a binding: it resolves or resolution stops, never another plan (issue #237). With no `$PLAN_ID`, multiple named plans refuse selection. A single named plan may use `.planning/.active_plan` or discovery by mtime; otherwise resolution falls back to the project root (legacy). Used internally by hooks.
|
||||
- `scripts/check-complete.sh` — Verify all phases in the active plan are complete.
|
||||
- `scripts/session-catchup.py`: Explicit same-project session-record aggregation or bounded replay (`--metadata` / `--replay`); bare invocation does not access host history.
|
||||
- `scripts/attest-plan.sh` (and `.ps1`) — Lock the current `task_plan.md` content with a SHA-256 attestation (v2.37.0). Hooks then refuse to inject plan content if the file diverges from the attested hash. Use `--show` to print the stored hash, `--clear` to remove the attestation. See `/plan-attest` command.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "planning-with-files",
|
||||
"version": "3.16.1",
|
||||
"version": "3.17.2",
|
||||
"description": "Persistent project planning with selected context injection. Automatic recovery uses project files only; explicit catchup modes read same-project local session records for aggregate counts or bounded replay. The host-aware gate never runs Markdown-declared commands. No network upload path. Ships the skill plus a Pi Coding Agent extension.",
|
||||
"keywords": [
|
||||
"pi-package",
|
||||
|
||||
@@ -404,6 +404,7 @@ function Resolve-PlanFile {
|
||||
$resolver = Join-Path $PSScriptRoot "resolve-plan-dir.ps1"
|
||||
if (-not (Test-Path -LiteralPath $resolver -PathType Leaf)) { return $null }
|
||||
$resolvedDir = @(& $resolver | Where-Object { $_ }) | Select-Object -First 1
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { return $null }
|
||||
if ($resolvedDir) {
|
||||
$planFile = Join-Path $resolvedDir "task_plan.md"
|
||||
return (Resolve-ContainedPlanFile -Candidate $planFile -ExpectedDirectory $resolvedDir)
|
||||
|
||||
@@ -45,6 +45,10 @@ resolve_plan_file() {
|
||||
plan_dir=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
plan_dir="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$plan_dir" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
printf "[plan-attest] Multiple plans are available. Set PLAN_ID=<slug>; nothing was attested.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [ -n "${plan_dir}" ] && [ -f "${plan_dir}/task_plan.md" ]; then
|
||||
printf "%s\n" "${plan_dir}/task_plan.md"
|
||||
|
||||
@@ -35,6 +35,7 @@ if ($PlanFile -ne "") {
|
||||
try {
|
||||
$resolvedDir = (& $resolver 2>$null | Select-Object -First 1)
|
||||
if ($null -eq $resolvedDir) { $resolvedDir = "" }
|
||||
if (-not $resolvedDir -and ((& $resolver -CheckAmbiguity) -eq "PWF_PLAN_AMBIGUOUS_V1")) { exit 0 }
|
||||
} catch {
|
||||
$resolvedDir = ""
|
||||
}
|
||||
|
||||
@@ -56,6 +56,9 @@ else
|
||||
RESOLVED_DIR=""
|
||||
if [ -f "${RESOLVER}" ]; then
|
||||
RESOLVED_DIR="$(sh "${RESOLVER}" 2>/dev/null)"
|
||||
if [ -z "$RESOLVED_DIR" ] && [ "$(sh "${RESOLVER}" --check-ambiguity 2>/dev/null)" = "PWF_PLAN_AMBIGUOUS_V1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
if [ -n "${RESOLVED_DIR}" ] && [ -f "${RESOLVED_DIR}/task_plan.md" ]; then
|
||||
PLAN_FILE="${RESOLVED_DIR}/task_plan.md"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ select_python_candidates() {
|
||||
is_windowsapps_path "$_sp_candidate" && continue
|
||||
[ -f "$_sp_candidate" ] || continue
|
||||
[ -x "$_sp_candidate" ] || continue
|
||||
if "$_sp_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
if "$_sp_candidate" -I -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_sp_candidate"
|
||||
return 0
|
||||
fi
|
||||
@@ -201,7 +201,7 @@ canonicalize() {
|
||||
printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
if [ -n "${PWF_PYTHON:-}" ]; then
|
||||
out="$("${PWF_PYTHON}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${PWF_PYTHON}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -254,6 +254,29 @@ is_within_root() {
|
||||
# The .active_plan pointer, the newest-by-mtime fallback, and the legacy root
|
||||
# task_plan.md are cwd GUESSES — only guesses are subject to the nested-root
|
||||
# conflict check below.
|
||||
# Shared .active_plan and directory mtime cannot identify this session's plan.
|
||||
# Check before selection or preflight, even when isolation was never armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_PREFIX}.planning/sessions" ] && [ -f "${PLAN_PREFIX}task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ] && { [ "$CONTEXT" = "preflight" ] || [ ! -d "${PLAN_PREFIX}.planning/sessions" ]; }; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RESOLVED=""
|
||||
SCOPE=""
|
||||
EXPLICIT=0
|
||||
@@ -334,7 +357,7 @@ if [ -d "${PLAN_PREFIX}.planning/sessions" ]; then
|
||||
# A current session ID always determines its own portable digest.
|
||||
# Ambient PWF_SESSION_KEY may belong to a previous session and is
|
||||
# intentionally ignored. Safe legacy raw sentinels remain compatible.
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
SESSION_ATTACHED=$("$PWF_PYTHON" -I - "${PWF_PLAN_ROOT:-.}" "$SESSIONS_DIR" "$SESSION_ID" <<'PY' 2>/dev/null
|
||||
import ctypes
|
||||
import hashlib
|
||||
import os
|
||||
@@ -442,27 +465,13 @@ PY
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# An attachment admits a session but does not select one of several plans.
|
||||
# When isolation is armed, require PLAN_ID if more than one live same-root
|
||||
# candidate exists. PWF_PLAN_ROOT selects the project root, not a plan
|
||||
# within that root.
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
SESSION_PLAN_N=0
|
||||
[ -f "${PLAN_PREFIX}task_plan.md" ] && SESSION_PLAN_N=1
|
||||
for candidate in "${PLAN_PREFIX}".planning/*/task_plan.md; do
|
||||
[ -f "$candidate" ] || continue
|
||||
candidate_dir="${candidate%/task_plan.md}"
|
||||
candidate_slug="${candidate_dir##*/}"
|
||||
slug_is_valid "$candidate_slug" || continue
|
||||
SESSION_PLAN_N=$((SESSION_PLAN_N + 1))
|
||||
[ "$SESSION_PLAN_N" -gt 1 ] && break
|
||||
done
|
||||
if [ "$SESSION_PLAN_N" -gt 1 ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
# Attachment admits a session but does not select its plan. Preserve the
|
||||
# attachment-first notice above for sessions that never opted in.
|
||||
if [ "$PLAN_AMBIGUOUS" = "1" ]; then
|
||||
if [ "$CONTEXT" = "userprompt" ]; then
|
||||
echo "[planning-with-files] Multiple plans are available while session isolation is armed. Set PLAN_ID=<slug> for this session; nothing injected."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -605,7 +614,7 @@ cleanup_snapshot() {
|
||||
# resolved path remains inside the canonical root.
|
||||
safe_snapshot() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "${PWF_PLAN_ROOT:-.}" "$3" <<'PY'
|
||||
import ctypes
|
||||
import os
|
||||
import stat
|
||||
@@ -754,7 +763,7 @@ PY
|
||||
# content, or non-private cache directories are rejected.
|
||||
secure_progress_marker() {
|
||||
[ -n "$PWF_PYTHON" ] || return 1
|
||||
"$PWF_PYTHON" - "$1" "$2" "$3" "$4" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$1" "$2" "$3" "$4" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
# junction/symlink escape; slug validation alone blocks textual traversal.
|
||||
|
||||
param(
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning")
|
||||
[string]$PlanRoot = (Join-Path (Get-Location) ".planning"),
|
||||
[switch]$CheckAmbiguity
|
||||
)
|
||||
|
||||
$projectRoot = (Get-Location).Path
|
||||
@@ -137,6 +138,30 @@ $activeFile = Join-Path $PlanRoot ".active_plan"
|
||||
# at rc=0. Emptiness is the fail-closed signal on this channel, matching
|
||||
# resolve-plan-dir.sh and the PWF_PLAN_ROOT pin. An empty $env:PLAN_ID is
|
||||
# falsy here and still means "unset".
|
||||
# The optional probe distinguishes ambiguity from a legacy-root fallback.
|
||||
# Multiple named plans require PLAN_ID even without a sessions directory.
|
||||
$planCount = 0
|
||||
if (-not $env:PLAN_ID) {
|
||||
if ((Test-Path -LiteralPath (Join-Path $PlanRoot "sessions") -PathType Container) -and
|
||||
(Test-Path -LiteralPath (Join-Path $projectRoot "task_plan.md") -PathType Leaf)) {
|
||||
$planCount = 1
|
||||
}
|
||||
if (Test-Path -LiteralPath $PlanRoot -PathType Container) {
|
||||
foreach ($entry in (Get-ChildItem -LiteralPath $PlanRoot -Directory -ErrorAction SilentlyContinue)) {
|
||||
if ((Test-ValidSlug $entry.Name) -and
|
||||
(Test-Path -LiteralPath (Join-Path $entry.FullName "task_plan.md") -PathType Leaf)) {
|
||||
$planCount++
|
||||
if ($planCount -gt 1) { break }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($CheckAmbiguity) {
|
||||
if ($planCount -gt 1) { Write-Output "PWF_PLAN_AMBIGUOUS_V1" }
|
||||
exit 0
|
||||
}
|
||||
if ($planCount -gt 1) { exit 0 }
|
||||
|
||||
if ($env:PLAN_ID) {
|
||||
if (Test-ValidSlug $env:PLAN_ID) {
|
||||
$candidate = Join-Path $PlanRoot $env:PLAN_ID
|
||||
|
||||
@@ -15,6 +15,13 @@
|
||||
|
||||
set -u
|
||||
|
||||
# Optional probe distinguishes ambiguity from the empty legacy-root result.
|
||||
# Both modes keep stdout data-only and always exit zero.
|
||||
CHECK_AMBIGUITY=0
|
||||
if [ "${1:-}" = "--check-ambiguity" ]; then
|
||||
CHECK_AMBIGUITY=1
|
||||
shift
|
||||
fi
|
||||
PLAN_ROOT="${1:-${PWD}/.planning}"
|
||||
|
||||
# --- PWF_PLAN_ROOT: absolute plan-root binding (issue #212). ---
|
||||
@@ -151,7 +158,7 @@ canonicalize() {
|
||||
fi
|
||||
_canonical_python="$(trusted_python)" || _canonical_python=""
|
||||
if [ -n "${_canonical_python}" ]; then
|
||||
out="$("${_canonical_python}" -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
out="$("${_canonical_python}" -I -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "${target}" 2>/dev/null)" \
|
||||
&& [ -n "${out}" ] && { printf "%s\n" "${out}"; return 0; }
|
||||
fi
|
||||
return 1
|
||||
@@ -233,7 +240,7 @@ mtime_of() {
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
_mtime_python="$(trusted_python)" || _mtime_python=""
|
||||
if [ -n "${_mtime_python}" ]; then
|
||||
out="$("${_mtime_python}" -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
out="$("${_mtime_python}" -I -c "import os,sys;print(int(os.stat(sys.argv[1]).st_mtime))" "${target}" 2>/dev/null)"
|
||||
if [ -n "${out}" ]; then printf "%s\n" "${out}"; return 0; fi
|
||||
fi
|
||||
printf "0\n"
|
||||
@@ -321,6 +328,29 @@ resolve_latest_dir() {
|
||||
# the fail-closed signal on this channel, exactly as the PWF_PLAN_ROOT guard
|
||||
# above already does it; a non-zero status would kill callers running under
|
||||
# set -e for a condition that is not an internal error.
|
||||
# A shared pointer or mtime is not a per-session binding (issue #240).
|
||||
# Count conservatively, just like injection: slug-valid live plan files.
|
||||
# The legacy root joins the count only when session isolation is armed.
|
||||
PLAN_AMBIGUOUS=0
|
||||
if [ -z "${PLAN_ID:-}" ]; then
|
||||
PLAN_COUNT=0
|
||||
if [ -d "${PLAN_ROOT}/sessions" ] && [ -f "${PWF_ROOT_PIN:-.}/task_plan.md" ]; then
|
||||
PLAN_COUNT=1
|
||||
fi
|
||||
for plan_candidate in "${PLAN_ROOT}"/*/task_plan.md; do
|
||||
[ -f "$plan_candidate" ] || continue
|
||||
plan_candidate_dir="${plan_candidate%/task_plan.md}"
|
||||
slug_is_valid "${plan_candidate_dir##*/}" || continue
|
||||
PLAN_COUNT=$((PLAN_COUNT + 1))
|
||||
if [ "$PLAN_COUNT" -gt 1 ]; then PLAN_AMBIGUOUS=1; break; fi
|
||||
done
|
||||
fi
|
||||
if [ "$CHECK_AMBIGUITY" = "1" ]; then
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && printf '%s\n' 'PWF_PLAN_AMBIGUOUS_V1'
|
||||
exit 0
|
||||
fi
|
||||
[ "$PLAN_AMBIGUOUS" = "1" ] && exit 0
|
||||
|
||||
if [ -n "${PLAN_ID:-}" ]; then
|
||||
resolve_from_env && exit 0
|
||||
exit 0
|
||||
|
||||
@@ -33,12 +33,115 @@ INJECT_PLAN="${SCRIPT_DIR}/inject-plan.sh"
|
||||
GATE_STOP="${SCRIPT_DIR}/gate-stop.sh"
|
||||
CHECK_COMPLETE="${SCRIPT_DIR}/check-complete.sh"
|
||||
|
||||
FAST_PATH="${SCRIPT_DIR}/inject-plan.py"
|
||||
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
|
||||
# No planning state where the resolver will look and no selector to validate:
|
||||
# every event below answers with nothing (and Stop is not consumed until a
|
||||
# plan is accepted), so answer with nothing now, before any fork. A set
|
||||
# PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice from the injector.
|
||||
if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
|
||||
&& [ ! -f task_plan.md ] && [ ! -d .planning ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Locate a CPython 3 without forking (v3.17.0). Every $(...) and every
|
||||
# pipeline is a fork, and under Git Bash on Windows a fork costs about 90 ms;
|
||||
# the old `$(command -v ...)` plus a `-c` version probe cost three of them on
|
||||
# every event. This walk is stat calls only. Explicit PWF_TRUSTED_PYTHON or
|
||||
# PYTHON_BIN wins; otherwise python3 is preferred over python across the whole
|
||||
# PATH so an old distro's Python 2 `python` is never picked while a python3
|
||||
# exists further down. Only absolute PATH entries are searched (a relative or
|
||||
# empty entry would let the current repository plant the interpreter) and the
|
||||
# Microsoft Store aliases are skipped by path: they are discoverable yet refuse
|
||||
# to run a script. Python stays optional: without it the payload is still
|
||||
# consumed to EOF, the session id is treated as absent, and the PostToolUse
|
||||
# throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
|
||||
[ -n "$_fp_explicit" ] || continue
|
||||
case "$_fp_explicit" in
|
||||
/*|[A-Za-z]:[\\/]*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_explicit" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
|
||||
printf '%s\n' "$_fp_explicit"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
_fp_found=""
|
||||
# set -u is active: an unset IFS or PATH must not kill the hook.
|
||||
if [ "${IFS+set}" = set ]; then
|
||||
_fp_saved_ifs="$IFS"
|
||||
_fp_ifs_was_set=1
|
||||
else
|
||||
_fp_saved_ifs=""
|
||||
_fp_ifs_was_set=0
|
||||
fi
|
||||
for _fp_name in python3 python; do
|
||||
IFS=:
|
||||
set -f
|
||||
for _fp_dir in ${PATH-}; do
|
||||
case "$_fp_dir" in
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_fp_dir" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
|
||||
_fp_found="${_fp_dir}/${_fp_name}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
set +f
|
||||
if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
|
||||
if [ -n "$_fp_found" ]; then
|
||||
printf '%s\n' "$_fp_found"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON=""
|
||||
select_python_into_var() {
|
||||
# Assign without a subshell: the walk above is the only work this costs.
|
||||
_spv_out="$(select_python 2>/dev/null)" || _spv_out=""
|
||||
PWF_PYTHON="$_spv_out"
|
||||
}
|
||||
select_python_into_var
|
||||
|
||||
# Run the injector for one context. scripts/inject-plan.py is a byte-identical
|
||||
# twin of inject-plan.sh in one interpreter process (about 130 forks fewer per
|
||||
# event; see the header of hooks/claude-hook.sh). It exits 0 only when its
|
||||
# stdout is the complete answer, so any other status falls back to the
|
||||
# reference chain. PWF_FAST_PATH=0 forces the reference chain. -I keeps the
|
||||
# project directory off sys.path; -B never writes bytecode into the skill dir.
|
||||
# PWF_SHELL_PWD hands the twin this shell's $PWD spelling so both routes
|
||||
# derive the same cache slots; MSYS2_ENV_CONV_EXCL keeps Git Bash from
|
||||
# rewriting it on the way.
|
||||
run_inject() {
|
||||
if [ "${PWF_FAST_PATH:-}" != "0" ] && [ -n "$PWF_PYTHON" ] && [ -f "$FAST_PATH" ]; then
|
||||
if PWF_SHELL_PWD="$PWD" \
|
||||
MSYS2_ENV_CONV_EXCL="${MSYS2_ENV_CONV_EXCL:+${MSYS2_ENV_CONV_EXCL};}PWF_SHELL_PWD" \
|
||||
"$PWF_PYTHON" -I -B "$FAST_PATH" "--context=$1" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
sh "$INJECT_PLAN" "--context=$1" 2>/dev/null
|
||||
}
|
||||
|
||||
# Keep the injector's established no-probe boundary. The preflight token is
|
||||
# emitted only after a plan exists as a regular contained file, but before
|
||||
# session admission needs stdin identity. Rejected paths must not make this
|
||||
# wrapper execute a PATH interpreter merely to parse a payload it will ignore.
|
||||
[ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# wrapper execute any interpreter, so the preflight and the refusal notices
|
||||
# stay on the shell chain; the twin runs only once the plan is accepted.
|
||||
_preflight="$(sh "$INJECT_PLAN" --context=preflight 2>/dev/null)" || exit 0
|
||||
if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
case "$EVENT" in
|
||||
@@ -47,43 +150,6 @@ if [ "$_preflight" != "PWF_PLAN_ELIGIBLE_V1" ]; then
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Select a runnable Python only for strict JSON parsing. Python is optional:
|
||||
# without it the payload is still consumed to EOF, the session id is treated as
|
||||
# absent, and the PostToolUse throttle deliberately degrades to repeat output.
|
||||
select_python() {
|
||||
if [ -n "${PWF_TRUSTED_PYTHON:-}" ]; then
|
||||
set -- "$PWF_TRUSTED_PYTHON"
|
||||
elif [ -n "${PYTHON_BIN:-}" ]; then
|
||||
set -- "$PYTHON_BIN"
|
||||
else
|
||||
set -- "$(command -v python3 2>/dev/null)" "$(command -v python 2>/dev/null)"
|
||||
fi
|
||||
for _candidate in "$@"
|
||||
do
|
||||
[ -n "$_candidate" ] || continue
|
||||
case "$_candidate" in
|
||||
[A-Za-z]:[\\/]*)
|
||||
_cygpath="/usr/bin/cygpath.exe"
|
||||
[ -f "$_cygpath" ] && [ -x "$_cygpath" ] || continue
|
||||
_candidate="$("$_cygpath" -u "$_candidate" 2>/dev/null)" || continue
|
||||
;;
|
||||
/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
case "$_candidate" in
|
||||
*[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
|
||||
esac
|
||||
[ -f "$_candidate" ] && [ -x "$_candidate" ] || continue
|
||||
if "$_candidate" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 8) else 1)' >/dev/null 2>&1; then
|
||||
printf '%s\n' "$_candidate"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
PWF_PYTHON="$(select_python 2>/dev/null)" || PWF_PYTHON=""
|
||||
PARSED_IDENTITY=""
|
||||
HOOK_PAYLOAD=""
|
||||
if [ "$EVENT" = "stop" ]; then
|
||||
@@ -94,7 +160,7 @@ if [ "$EVENT" = "stop" ]; then
|
||||
HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
|
||||
fi
|
||||
parse_identity() {
|
||||
"$PWF_PYTHON" -c '
|
||||
"$PWF_PYTHON" -I -c '
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
@@ -190,7 +256,7 @@ clear_turn_marker() {
|
||||
cache_action() {
|
||||
_cache_action="$1"
|
||||
_cache_root="$2"
|
||||
"$PWF_PYTHON" - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
"$PWF_PYTHON" -I - "$_cache_action" "$_cache_root" "$TURN_KEY" "$PROMPT_ID" <<'PY'
|
||||
import os
|
||||
import secrets
|
||||
import stat
|
||||
@@ -328,10 +394,12 @@ claim_turn_marker() {
|
||||
|
||||
# Encode the injector's bounded output without interpolating it into a command
|
||||
# or format string. Walk characters directly because awk implementations do
|
||||
# not agree on how many escapes gsub replacement text consumes.
|
||||
# not agree on how many escapes gsub replacement text consumes. LC_ALL=C
|
||||
# makes the walk byte-wise: in a UTF-8 locale gawk on Windows walks UTF-16
|
||||
# units and re-emits a character outside the BMP as a lone surrogate.
|
||||
json_string() {
|
||||
tr '\001-\011\013-\037' ' ' \
|
||||
| awk 'BEGIN { first = 1 }
|
||||
| LC_ALL=C awk 'BEGIN { first = 1 }
|
||||
{
|
||||
if (!first) printf "\\n"
|
||||
for (i = 1; i <= length($0); i++) {
|
||||
@@ -359,15 +427,15 @@ case "$EVENT" in
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
# Plain stdout is explicitly model context for UserPromptSubmit. Do
|
||||
# not capture or reframe it: preserve injector output byte-for-byte.
|
||||
sh "$INJECT_PLAN" --context=userprompt 2>/dev/null || :
|
||||
run_inject userprompt || :
|
||||
;;
|
||||
pretool)
|
||||
_context="$(sh "$INJECT_PLAN" --context=pretool 2>/dev/null)" || exit 0
|
||||
_context="$(run_inject pretool)" || exit 0
|
||||
emit_context_json "PreToolUse" "$_context"
|
||||
;;
|
||||
posttool)
|
||||
[ -f "$INJECT_PLAN" ] || exit 0
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
claim_turn_marker || exit 0
|
||||
printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}}'
|
||||
@@ -376,10 +444,10 @@ case "$EVENT" in
|
||||
# PreCompact does not support additionalContext. Preserve the current
|
||||
# plain diagnostic output and pass only the real session identity into
|
||||
# resolution; do not invent an unsupported event-specific JSON field.
|
||||
sh "$INJECT_PLAN" --context=precompact 2>/dev/null || :
|
||||
run_inject precompact || :
|
||||
;;
|
||||
stop)
|
||||
_decision="$(sh "$INJECT_PLAN" --context=validate 2>/dev/null)" || exit 0
|
||||
_decision="$(run_inject validate)" || exit 0
|
||||
[ "$_decision" = "PWF_PLAN_ACCEPTED_V1" ] || exit 0
|
||||
if [ -f "$GATE_STOP" ]; then
|
||||
printf '%s' "$HOOK_PAYLOAD" | sh "$GATE_STOP" 2>/dev/null || :
|
||||
|
||||
@@ -1,161 +1,28 @@
|
||||
# AGENTS.md — planning-with-files agent reference card
|
||||
# AGENTS.md, planning-with-files maintainer rules
|
||||
|
||||
This file is the canonical, session-portable reference for how every agent working in this repo must handle commits, releases, version bumps, CHANGELOG entries, and issue/PR communication.
|
||||
For any agent doing releases, merges or issue work in this repository. The code and `scripts/` are discoverable; this file holds the decisions that are not.
|
||||
|
||||
---
|
||||
## Authorship
|
||||
- Contributor commits keep the contributor as `Author:`. Merge with `git fetch origin pull/N/head:pr-N && git cherry-pick <sha>` or `gh pr merge --rebase`. Never `git merge --squash` a contributor PR: it reassigns their commit to whoever runs the local commit, which happened once in the v2.40.1 cycle. Squash only your own WIP before pushing.
|
||||
- Release and maintenance commits are authored by OthmanAdi alone, Conventional Commits (`fix:`, `feat:`, `release:`, `docs:`), no `Co-Authored-By`. Contributors are credited in the CHANGELOG `### Thanks` section and in `CONTRIBUTORS.md`, never in trailers.
|
||||
- No `--no-verify`. No force push to master except tag ref updates and history corrections Adi explicitly authorised.
|
||||
|
||||
## Commit rules
|
||||
## Release flow
|
||||
1. Read the issue and the PR in full (`gh issue view N`, `gh pr view N`). Reproduce the claim against the code. Audit the diff for supply-chain vectors (new dependencies, install scripts, bin shims, files in the install path). Comment on the issue the moment it is confirmed, with the planned fix; the closing comment comes after shipping. Never batch all communication to the end.
|
||||
2. `python -m pytest tests/ -q` is green before and after the merge.
|
||||
3. Merge the contributor commits as above, then one release commit on top: CHANGELOG entry, CONTRIBUTORS.md (entry, total count, date), README version badge and releases table row, version bump.
|
||||
4. Bump with `python scripts/bump-version.py X.Y.Z` (`--dry-run` first), never by hand. `tests/test_skill_md_version_parity.py` defines the parity set (19 tracked files plus the gitignored `clawhub-upload/SKILL.md` when present); the script and the test are the source of truth, not any list in prose. Deliberately lagging: `.continue` and `.gemini` (bump only on an explicit scope decision), `.kiro` (own `-kiro` scheme), `.pi/.../SKILL.md` (no version field; the Pi version is its `package.json`, which is in the set). The bundled Pi extension's own `package.json` moves only when that extension changed.
|
||||
5. Tag `vX.Y.Z` on the release commit, push master and the tag, then `gh release create vX.Y.Z --title "vX.Y.Z - <short description>" --notes "<what changed, then Thanks>"`.
|
||||
6. Distribution is manual after every release. ClawHub: `python scripts/build-clawhub-upload.py`, then `python scripts/build-clawhub-upload.py --verify` (the staged folder must match the tracked inventory), then upload the whole `clawhub-upload/` folder at clawhub.io (its SSL certificate may be expired; proceed through the warning). npm: `npm publish` from `.pi/skills/planning-with-files/` (the unscoped package `planning-with-files`, Adi's account; the abandoned `@tomxprime/planning-with-files` and `pi-planning-with-files` are never touched). skills.sh and `npx skills` pull master on their own; the Anthropic marketplace reflects the ClawHub upload.
|
||||
7. Comment on the PR and the issue (contributor's @handle, the version that fixes it, root cause and mechanism, "you are in CONTRIBUTORS.md" when true, the commit SHA so it auto-links), then close what GitHub did not close.
|
||||
|
||||
- **Author**: OthmanAdi only for release/maintenance commits. NEVER add `Co-Authored-By:` trailers.
|
||||
- **Format**: Conventional Commits — `fix:`, `feat:`, `release:`, `docs:` prefixes.
|
||||
- **One release commit on top of the contributor commit(s), never a squash of the contributor's work.** `git merge --squash` rewrites the committer as whoever runs the local commit, which reassigns the contributor's authorship to OthmanAdi — this happened once (v2.40.1 cycle) and is exactly what this rule exists to prevent. Squashing is fine only for collapsing your OWN WIP commits before pushing.
|
||||
- No `--no-verify`. No force push to master except tag ref updates.
|
||||
- Contributors are credited in CHANGELOG `### Thanks` and `CONTRIBUTORS.md`, never in commit trailers.
|
||||
## Formats
|
||||
- CHANGELOG: `## [X.Y.Z] - YYYY-MM-DD`, then `### Added|Fixed|Changed|Security`, then `### Thanks` with one line per contributor (first name or @handle, what they did, issue or PR number).
|
||||
- CONTRIBUTORS.md: `**[Name](https://github.com/handle)** — [PR #N](link)` plus one bullet per contribution; "Other Contributors" for a single fix, "Major Contributions" for larger work; update the total and the "Last updated" date.
|
||||
- Release notes start with what changed; Thanks at the bottom.
|
||||
- All public prose (comments, notes, CHANGELOG) is matter-of-fact: no em-dashes, no "Great report!" or "Thank you so much!", no "I'd like to". Run it through `/humanizer` before posting.
|
||||
|
||||
---
|
||||
|
||||
## Release checklist (12 steps)
|
||||
|
||||
1. `gh issue view N` and `gh pr view N` — read both in full.
|
||||
2. Verify the bug is real: find the exact file/line, grep for the pattern, confirm reporter is correct.
|
||||
3. `python -m pytest tests/ -q` — all tests pass before touching anything.
|
||||
4. Merge preserving contributor authorship: `git fetch origin pull/N/head:pr-N && git cherry-pick <pr-head-sha>`, or `gh pr merge --rebase`. Do NOT use `git merge --squash` — it collapses the contributor's commit and reassigns the `Author:` field to whoever runs the local commit, destroying their credit in `git log`.
|
||||
5. CHANGELOG — new version entry at top, `### Fixed`/`### Added`/`### Changed`, sachlich, no em-dashes.
|
||||
6. CONTRIBUTORS.md — add reporter/contributor, bump "Total Contributors: N+", update "Last updated" date.
|
||||
7. Version bump across all 19 tracked targets plus the local ClawHub staging target when present (see table below). Then run `python scripts/build-clawhub-upload.py` and `python scripts/build-clawhub-upload.py --verify`; verification must report that the complete staging folder matches the canonical tracked inventory.
|
||||
8. README — update version badge and add row to releases table.
|
||||
9. `git commit`, `git tag vX.Y.Z`, `git push origin master`, `git push origin vX.Y.Z`.
|
||||
10. `gh release create vX.Y.Z --title "vX.Y.Z - <short description>" --notes "<release notes>"`.
|
||||
11. Post comment on PR and/or issue via `gh issue comment N --body "..."` (run through /humanizer first).
|
||||
12. `gh issue close N` if applicable.
|
||||
|
||||
---
|
||||
|
||||
## Version bump scope
|
||||
|
||||
The maintained version parity set has 20 entries: 19 tracked files plus the version-bearing `clawhub-upload/SKILL.md` inside the gitignored publish stage. Every present version target must use the same version string. `scripts/bump-version.py` reports the ClawHub stage as optional when it is absent from a fresh clone, but updates and validates its `SKILL.md` when present. Maintainer releases must rebuild the complete stage from the canonical tracked inventory with `python scripts/build-clawhub-upload.py`, then run `python scripts/build-clawhub-upload.py --verify` before manual upload.
|
||||
|
||||
| File | Notes |
|
||||
|------|-------|
|
||||
| `skills/planning-with-files/SKILL.md` | Primary English |
|
||||
| `skills/i18n/planning-with-files-ar/SKILL.md` | Arabic |
|
||||
| `skills/i18n/planning-with-files-de/SKILL.md` | German |
|
||||
| `skills/i18n/planning-with-files-es/SKILL.md` | Spanish |
|
||||
| `skills/i18n/planning-with-files-zh/SKILL.md` | Simplified Chinese |
|
||||
| `skills/i18n/planning-with-files-zht/SKILL.md` | Traditional Chinese |
|
||||
| `.codebuddy/skills/planning-with-files/SKILL.md` | CodeBuddy IDE |
|
||||
| `.codex/skills/planning-with-files/SKILL.md` | Codex IDE |
|
||||
| `.cursor/skills/planning-with-files/SKILL.md` | Cursor IDE |
|
||||
| `.factory/skills/planning-with-files/SKILL.md` | Factory IDE |
|
||||
| `.hermes/skills/planning-with-files/SKILL.md` | Hermes Agent skill bundle (the native plugin with tools, `/pwf`, hooks and the `pre_verify` gate lives in `.hermes/plugins/planning-with-files/`, versioned separately in its `plugin.yaml`) |
|
||||
| `.mastracode/skills/planning-with-files/SKILL.md` | Mastra Code |
|
||||
| `.opencode/skills/planning-with-files/SKILL.md` | OpenCode IDE |
|
||||
| `.pi/skills/planning-with-files/package.json` | npm package manifest |
|
||||
| `.agents/skills/planning-with-files/SKILL.md` | Agent Skills standard layout (Zed, Amp, Warp, Devin, Antigravity, Gemini CLI read this path natively; added v3.7.0) |
|
||||
| `clawhub-upload/SKILL.md` | Version-bearing file inside the complete gitignored ClawHub marketplace stage; optional in a fresh clone |
|
||||
| `.claude-plugin/plugin.json` | Plugin manifest |
|
||||
| `.claude-plugin/marketplace.json` | Marketplace metadata |
|
||||
| `.codex-plugin/plugin.json` | Codex plugin manifest |
|
||||
| `CITATION.cff` | Citation file |
|
||||
|
||||
**NOT bumped automatically**: `scripts/bump-version.py`'s `LAGGING_FILES` list currently excludes four files, not two — this table only tracked two until this correction:
|
||||
- `.continue/skills/planning-with-files/SKILL.md`, `.gemini/skills/planning-with-files/SKILL.md` — intentionally behind. Do not bump without an explicit scope decision.
|
||||
- `.pi/skills/planning-with-files/SKILL.md` — carries no `version` field at all; the Pi channel's version lives in `.pi/skills/planning-with-files/package.json` (the npm package `planning-with-files`), which since v3.9.0 IS part of the parity set and bumped by `bump-version.py`. Publishing to npm (`npm publish` from that folder) is a manual step after each release, like the ClawHub upload.
|
||||
- `.kiro/skills/planning-with-files/SKILL.md` — carries its own `-kiro`-suffixed scheme (e.g. `3.0.0-kiro`), bumped on Kiro-relevant changes rather than every canonical release.
|
||||
|
||||
Recent CHANGELOG entries (v3.1.1–v3.1.3) already describe this 4-file exclusion as "per AGENTS.md release scope" — this section previously did not actually say so. It does now.
|
||||
|
||||
---
|
||||
|
||||
## CHANGELOG format
|
||||
|
||||
```
|
||||
## [X.Y.Z] - YYYY-MM-DD
|
||||
|
||||
### Fixed
|
||||
- Short description of what was wrong and how it was fixed.
|
||||
|
||||
### Thanks
|
||||
- @handle — what they contributed (issue #N / PR #N)
|
||||
```
|
||||
|
||||
Rules:
|
||||
- Sachlich (matter-of-fact). No em-dashes. No hype.
|
||||
- Contributor line: first name or @handle, one sentence, issue/PR reference.
|
||||
- Run any prose through /humanizer before publishing anywhere public.
|
||||
|
||||
---
|
||||
|
||||
## CONTRIBUTORS.md format
|
||||
|
||||
```markdown
|
||||
### Other Contributors
|
||||
|
||||
**[Name](https://github.com/handle)** — [PR #N](link) / [Issue #N](link)
|
||||
- What they did (one bullet per contribution)
|
||||
- Impact or context
|
||||
```
|
||||
|
||||
- Update "Total Contributors: N+" count.
|
||||
- Update "Last updated: YYYY-MM-DD" date.
|
||||
- Scope determines section: "Other Contributors" for single-issue fix, "Major Contributions" for larger work.
|
||||
|
||||
---
|
||||
|
||||
## Issue/PR comment style
|
||||
|
||||
After a fix ships, comment on the issue or PR:
|
||||
|
||||
- Address by `@handle`.
|
||||
- One sentence: fix confirmed in vX.Y.Z.
|
||||
- Specific: what the root cause was, what mechanism changed.
|
||||
- If they are now in CONTRIBUTORS.md, say so.
|
||||
- Run through /humanizer before posting.
|
||||
|
||||
NOT acceptable in any public comment:
|
||||
- "Great report!"
|
||||
- "Thank you so much!"
|
||||
- Em-dashes (do not use — this style)
|
||||
- "I'd like to"
|
||||
- Performative warmth of any kind
|
||||
|
||||
---
|
||||
|
||||
## Release notes format (gh release create --notes)
|
||||
|
||||
```
|
||||
What changed:
|
||||
|
||||
- <Bug description> — <what the fix does>
|
||||
- <Feature description> — <how it works>
|
||||
|
||||
Thanks: @handle for reporting issue #N.
|
||||
```
|
||||
|
||||
- Start with what changed, not who did it.
|
||||
- No em-dashes.
|
||||
- Thanks at the bottom.
|
||||
|
||||
---
|
||||
|
||||
## ClawHub distribution
|
||||
|
||||
- ClawHub does NOT auto-sync with GitHub.
|
||||
- After every release, run `python scripts/build-clawhub-upload.py`.
|
||||
- Run `python scripts/build-clawhub-upload.py --verify` and require the complete folder to match the canonical tracked inventory.
|
||||
- Manually upload the entire `clawhub-upload/` folder at clawhub.io.
|
||||
- SSL cert on clawhub.io may be expired — proceed through the browser warning.
|
||||
- skills.sh / `npx skills`: pulls from GitHub master automatically on next crawl.
|
||||
- Anthropic plugin marketplace: requires ClawHub upload to reflect the new version.
|
||||
|
||||
---
|
||||
|
||||
## Quick reference: what NOT to do
|
||||
|
||||
- Do not add Co-Authored-By to any commit.
|
||||
- Do not bump `.continue` or `.gemini` without explicit instruction. `.kiro` has its own version scheme, and `.pi/skills/planning-with-files/SKILL.md` has no version field. The Pi npm version in `.pi/skills/planning-with-files/package.json` is part of the canonical parity set.
|
||||
- Do not `git merge --squash` a contributor PR — it reassigns their commit authorship. Use cherry-pick or `gh pr merge --rebase`.
|
||||
- Do not edit `task_plan.md` or `DESIGN.md` directly (user-owned contracts).
|
||||
- Do not log subagent returns into `task_plan.md` — use `progress.md`.
|
||||
- Do not use em-dashes in any user-facing prose.
|
||||
- Do not skip ClawHub upload after a release.
|
||||
## Repo contracts (orchestrator architecture, locked 2026-04-22)
|
||||
- `task_plan.md` and `DESIGN.md` are user-owned; agents never edit them directly. Subagent returns go to `progress.md`, never `task_plan.md`. Design tokens and research notes are appended to `findings.md` under a `## Design Context` heading.
|
||||
- Markdown on disk is the shared state across agents; no runtime-only state.
|
||||
- The memory layer wraps `code-memory-router`; it does not replace it.
|
||||
|
||||
@@ -4,6 +4,46 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [3.17.2] - 2026-09-09
|
||||
|
||||
### Fixed
|
||||
- The native Codex plugin explicitly disables legacy command migration with `"commands": []`. Codex no longer turns the 13 top-level Claude commands into redundant `source-command-*` skills when installing the plugin. The canonical planning skill and Codex hooks remain configured, and Claude retains its commands (#241).
|
||||
|
||||
### Thanks
|
||||
- @sunznx, for reporting the duplicate skills, tracing the fallback, and proposing the scoped manifest fix in #241.
|
||||
|
||||
## [3.17.1] - 2026-09-08
|
||||
|
||||
### Fixed
|
||||
- Multiple named plans now require `PLAN_ID` even when `.planning/sessions/` does not exist. A shared `.active_plan` pointer or directory modification time can no longer silently redirect a Codex session after compaction (#240).
|
||||
- Shell, PowerShell and Python selection paths refuse ambiguous plans. UserPromptSubmit explains the missing pin; per-tool and PreCompact hooks remain quiet, and Stop and attestation do not fall back to an unrelated root plan. Explicit pins, single named plans and legacy root plans remain supported.
|
||||
|
||||
### Thanks
|
||||
- @sunznx, for the same-cwd Codex regression report and reproduction in #240.
|
||||
|
||||
## [3.17.0] - 2026-09-07
|
||||
|
||||
Every Claude Code hook fire forked about 130 processes. On Windows that took longer than the hook timeout, so the plan never reached the model. Found on the maintainer's own machine the day after 3.16.1 shipped.
|
||||
|
||||
### Fixed
|
||||
- **The Claude Code plugin hooks timed out on Windows and Claude Code discarded the plan context.** `hooks/claude-hook.sh` answered every event by running `resolve-plan-dir.sh` and `inject-plan.sh`, and those answer by forking: `realpath`, `stat`, `sha256sum`, `awk`, `tr`, `mktemp`, `head`, `tail`, `sed`, `wc`, four separate Python starts, and a `$(...)` around most of them. One UserPromptSubmit fire forks about 130 times, one PreToolUse fire about 60. On Linux and macOS a fork costs one to three milliseconds and nobody noticed. Under Git Bash on Windows a fork costs about 90 ms, so a prompt paid 7 to 12 seconds against the 10 second hook timeout ("UserPromptSubmit hook timed out after 10s - output discarded"), and every Bash, Read, Grep and Edit call waited 5 more seconds in PreToolUse before it ran. Measured on the reporting machine: UserPromptSubmit 8.1 s, 10.2 s and 7.1 s across three fires, PreToolUse 5.5 s. The Codex route never had this because its Windows launcher starts Python directly.
|
||||
- **The events now run in one Python process.** New `scripts/inject-plan.py` is a byte-identical twin of `inject-plan.sh` plus the dispatcher logic of `claude-hook.sh` for session-start, user-prompt-submit, pre-tool-use, post-tool-use and pre-compact. The launcher finds a CPython 3 on PATH with a fork-free walk (absolute entries only, Microsoft Store aliases skipped, `python3` preferred over `python` across the whole PATH) and runs the twin with `python -I -B`. The twin exits 0 only when its stdout is the complete answer; any other status falls through to the unchanged shell chain, so a host without Python, or with a Python 2 `python`, behaves exactly as before. `PWF_FAST_PATH=0` forces the shell chain. The Stop event stays in the shell because it must forward Claude's stdin payload to `gate-stop.sh`. Same machine after the change: UserPromptSubmit 0.33 s, PreToolUse 0.28 to 0.37 s, PostToolUse 0.26 s, SessionStart 0.31 s.
|
||||
- **The standalone skill route takes the same fast path once a plan is accepted.** `skill-hook.sh` keeps the preflight and the refusal notices on the shell chain, because that route is pinned never to start an interpreter for a disabled or plan-less state, and runs the four injector calls after eligibility through the twin. Its interpreter discovery is the same fork-free PATH walk instead of two `$(command -v ...)` forks plus a `-c` version probe.
|
||||
- **A directory with no planning state answers before any fork.** Both dispatchers exit at once when the cwd has no `task_plan.md`, no `.planning` and no `PLAN_ID` or `PWF_PLAN_ROOT` selector: every route answers with nothing there, and the reference chain took about ten forks to say so. A set selector still gets its refusal notice.
|
||||
- **Both routes share one cache slot per plan.** The launchers hand the twin the shell's own `$PWD` spelling (`PWF_SHELL_PWD`, excluded from MSYS path conversion), so a fast-path fire and a fallback fire derive the same turn-marker slot (#239) and the same progress-guard slot (#217). Without that, Git Bash spelled the directory `/tmp/...` and Python `C:\Users\...`, and a switch between routes nudged twice in one turn and lost the guard's baseline.
|
||||
- **Characters outside the Basic Multilingual Plane survive the plugin's JSON encoder on Windows.** The `awk` walk in `json_string` used UTF-16 units under a UTF-8 locale and re-emitted an emoji in a plan as a lone surrogate, which is not UTF-8. Both dispatchers now run that walk under `LC_ALL=C`, byte by byte.
|
||||
|
||||
### Security
|
||||
- **Hook interpreters run in isolated mode.** The `python -` heredocs and `-c` snippets in `inject-plan.sh`, `resolve-plan-dir.sh` and `skill-hook.sh` put the current directory first on `sys.path`, so a repository carrying its own `secrets.py`, `hashlib.py` or `ctypes.py` had that file imported by the hook on every prompt, with the hook's privileges. Every interpreter start in those three scripts and in the new twin now passes `-I`. A parity test plants six such modules in a project and asserts that neither route runs them and both still inject the plan. The Codex, Gemini and GitHub Copilot shell adapters still start their interpreters in default mode; that is the next item.
|
||||
|
||||
### Verification
|
||||
- `tests/test_inject_plan_python_parity.py` runs the shell reference and the twin over the same fixtures, each with its own cache root, and asserts identical stdout bytes: every injector context, every dispatcher event, notices and refusals, frame digests and truncation flags, the progress-regression guard across three fires, smart extraction on CRLF and inline status markers, attestation, autonomous and gated modes with ledgers, the root `.mode` floor, session isolation with legacy and digest sentinels, and nested-root ambiguity. Launcher tests prove the fast path is the one that runs, that a twin which cannot run falls back to the reference output, that a missing twin falls back, that Stop never takes the fast path, and that Microsoft Store aliases and relative PATH entries are never selected.
|
||||
- A second-model review of the twin against the shell chain found five real divergences before release, all fixed and each now pinned by a parity fixture: a NUL byte in `.active_plan` (command substitution drops it, so a UTF-16LE pointer without a BOM still names its plan), the awk quirk that prints `phases: /3 complete` for a plan with no completed phase, the CRLF progress tail under Git for Windows' sed, the cache-slot spelling above, and the surrogate corruption above. Three accepted differences remain and are documented in the twin's header: glob collation order in the nested-ambiguity list, BSD sed appending a newline to a progress file whose last line has none, and the spelling of a `PWF_PLAN_ROOT` pin in notices under Git Bash.
|
||||
|
||||
### Changed
|
||||
- `scripts/inject-plan.py` ships in every scripts directory that ships `inject-plan.sh` (the sync inventory, the `.agents` mirror, the npm package and the language variants), and the canonical and location parity tests pin it.
|
||||
- Version parity advances to 3.17.0.
|
||||
|
||||
## [3.16.1] - 2026-09-05
|
||||
|
||||
### Fixed
|
||||
|
||||
+2
-2
@@ -7,8 +7,8 @@ authors:
|
||||
- family-names: Adi
|
||||
given-names: Ahmad Othman Ammar
|
||||
alias: OthmanAdi
|
||||
version: "3.16.1"
|
||||
date-released: "2026-08-31"
|
||||
version: "3.17.2"
|
||||
date-released: "2026-09-09"
|
||||
license: MIT
|
||||
url: "https://github.com/OthmanAdi/planning-with-files"
|
||||
repository-code: "https://github.com/OthmanAdi/planning-with-files"
|
||||
|
||||
+6
-2
@@ -106,6 +106,10 @@ These amazing people have contributed code, documentation, or significant improv
|
||||
|
||||
### Other Contributors
|
||||
|
||||
- **[@sunznx](https://github.com/sunznx)**, [Issue #240](https://github.com/OthmanAdi/planning-with-files/issues/240), [Issue #241](https://github.com/OthmanAdi/planning-with-files/issues/241)
|
||||
- Reported and reproduced named-plan crossover between Codex sessions sharing a working directory after compaction.
|
||||
- Reported the 13 duplicate Codex command skills, traced the legacy command fallback, and proposed the native manifest setting that disables it.
|
||||
|
||||
- **[@hzura](https://github.com/hzura)**, [Issue #50](https://github.com/OthmanAdi/planning-with-files/issues/50)
|
||||
- Raised the same-repository parallel-task workflow that led to explicit plan selection and shared-file ownership guidance.
|
||||
|
||||
@@ -421,6 +425,6 @@ If you've contributed and don't see your name here, please open an issue! We wan
|
||||
|
||||
---
|
||||
|
||||
**Total Contributors:** 58+ and growing!
|
||||
**Total Contributors:** 59+ and growing!
|
||||
|
||||
*Last updated: 2026-09-05*
|
||||
*Last updated: 2026-09-09*
|
||||
|
||||
@@ -354,6 +354,9 @@ One hook fire measures 289ms wall-clock since the v3.6.0 optimization, down from
|
||||
|
||||
| Version | Highlights |
|
||||
|---------|------------|
|
||||
| **v3.17.2** | Fixes #241: the native Codex manifest disables legacy command migration, removing 13 redundant `source-command-*` skills from plugin installs. The canonical planning skill, Codex hooks, and Claude commands remain available. |
|
||||
| **v3.17.1** | Fixes #240: two named plans in the same project now require `PLAN_ID`, even without `.planning/sessions/`. A shared pointer or newest-plan guess cannot redirect a Codex session across compaction. Ambiguous hooks inject no plan and Stop does not gate against a guessed plan. |
|
||||
| **v3.17.0** | **Every Claude Code hook fire forked about 130 processes, and under Git Bash on Windows that took 7 to 12 seconds against the 10 second hook timeout.** Claude Code discarded the plan context ("UserPromptSubmit hook timed out after 10s") and every Bash, Read, Grep and Edit call waited 5 more seconds in PreToolUse before it ran. Linux and macOS never showed it because a fork costs milliseconds there. The events now run in one Python process, `scripts/inject-plan.py`, a byte-identical twin of the shell chain proven by a parity suite on all three CI legs, with the shell chain kept as the reference and as the fallback for hosts without Python: 0.3 s per prompt and per tool call on the reporting machine. Hook interpreters now start in isolated mode, so a repository's own `secrets.py` or `hashlib.py` is never imported by a hook. `PWF_FAST_PATH=0` forces the shell chain. |
|
||||
| **v3.16.1** | Attached Codex, Hermes and Pi sessions require an explicit plan when several tasks share an armed project. Standalone hooks deliver model context through the proper event fields, preserve native session identity and throttle progress reminders. Packages include the loop template and Stop dependencies; recovery and security guidance state the selected-plan and trust boundaries. |
|
||||
| **v3.16.0** | **The PostToolUse progress reminder was shown to you and never to Claude** (closes #239, reported by @sortakool). It was emitted as `systemMessage`, which Claude Code delivers to the user, so a sentence addressed to the model reached the person instead, after every `Write`, `Edit` and `Bash` call for a whole session. Both the plugin dispatcher and the Codex adapter now emit `hookSpecificOutput.additionalContext`, the shape the session-start path in the same file already used. The reminder is also throttled to once per turn instead of once per tool call, and `Bash` is off the PostToolUse matchers so `ls` and `git status` stop tripping a "record what you changed" nudge. PreToolUse keeps `Bash`. Fixing this surfaced one more copy of the #237 fallback in the plugin dispatcher, now closed. |
|
||||
| **v3.15.0** | **A mistyped `PLAN_ID` used to attest and inject a different plan, and a slug plan could switch off the project's own policy** (closes #237 and #238, both reported by @sortakool). An explicit `PLAN_ID` is now a binding in every resolver, shell, PowerShell, Hermes, OpenCode and Pi: it resolves or it stops, and every consumer that reads or writes the selected plan says which selector refused instead of quietly using the root plan. A project's root `.mode` is now a floor rather than a default that slug scope replaces, so creating a plan can no longer drop a committed attestation requirement or completion gate; a slug may raise strictness, never lower it. Also fixes `plan-doctor.sh` reporting `PASS injection: emits plan context` on a state where nothing was injected at all (closes #236): classification branches on the `===BEGIN-PWF-DATA` framing rather than substring-matching control strings against the plan body, so a plan quoting one of them no longer trips a false tamper warning and a reworded banner degrades to a warning instead of a silent PASS. 30 new tests, each with its own control arm. |
|
||||
@@ -648,6 +651,7 @@ The v3 line adds features aimed at long-running agentic runs. Each one is listed
|
||||
| `PWF_PLAN_ROOT=<abs path>` | v3.9.0 | Pins the thread to a project root by absolute path, which `PLAN_ID` cannot express. Use it when the agent's cwd is a shared parent such as `/workspace` while the work lives in `/workspace/project`. A pin that does not resolve stops injection instead of falling back. |
|
||||
| `PWF_SESSION_ID=<id>` | v2.36.0 | Identifies the session for plan attachment. Only consulted when `.planning/sessions/` exists, in which case a session sees plan context only if `.planning/sessions/<id>.attached` exists. Delete that directory to turn session isolation off. |
|
||||
| `PWF_INJECT=smart` | v3.8.0 | Replaces the fixed `head -50` injection window with the goal, next step, current phase, the full in-progress phase, and the last three decisions. |
|
||||
| `PWF_FAST_PATH=0` | v3.17.0 | Forces the Claude Code plugin and standalone skill hooks through the reference shell chain instead of `scripts/inject-plan.py`, the single-process twin that runs whenever a CPython 3 is on PATH. Both produce identical output; the twin is what keeps a hook fire under a second on Windows. |
|
||||
| `PWF_PLAN_GUARD=0` | v3.10.0 | Turns off the parallel-write guard, which is on by default. The guard compares checked items and completed phases against the previous hook fire and prints one advisory line when they go DOWN, meaning a second session overwrote work. A `plan-guard-off` token in `.mode` does the same. |
|
||||
| `PWF_MODE` | v2.39.0 | Pi extension runtime mode: `auto`, `parity`, `cache-safe`, `notify`. Also settable in `.pi/settings.json` under `planningWithFiles.mode`. |
|
||||
| `PWF_GATE_CAP` | v3.0.0 | Maximum consecutive Stop-gate blocks in gated mode. Default 20. |
|
||||
|
||||
@@ -228,3 +228,9 @@ Use the workspace install (Method 1) on Windows: the `commandWindows` entries us
|
||||
- **GitHub Issues:** https://github.com/OthmanAdi/planning-with-files/issues
|
||||
- **OpenAI Codex Hooks Docs:** https://developers.openai.com/codex/hooks
|
||||
- **OpenAI Codex Skills Docs:** https://developers.openai.com/codex/skills
|
||||
|
||||
### Multiple named plans in one project
|
||||
|
||||
As of v3.17.1, a project with more than one live named plan requires `PLAN_ID` for each Codex session, whether or not `.planning/sessions/` exists. Set the pin in the environment that launches the host. Exporting it inside a tool subprocess cannot change an already-running host. A shared `.planning/.active_plan` pointer cannot select a plan for that session.
|
||||
|
||||
When no pin is available, UserPromptSubmit explains the ambiguity and injects no plan. Per-tool and PreCompact hooks remain quiet, and Stop allows the session to end without evaluating a guessed plan. Explicit pins, single named plans and legacy root plans remain supported.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user