planning-with-files 3.11.2 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,8 @@
9
9
  # 1. $PLAN_ID env var → ./.planning/$PLAN_ID/
10
10
  # 2. ./.planning/.active_plan
11
11
  # 3. Newest ./.planning/<dir>/ by mtime
12
- # 4. Legacy ./task_plan.md at project root
12
+ # 4. Current directory when it is .planning/<valid-slug>/
13
+ # 5. Legacy ./task_plan.md at project root
13
14
  #
14
15
  # Usage:
15
16
  # sh scripts/attest-plan.sh # attest the active plan
@@ -21,6 +22,25 @@ set -u
21
22
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
22
23
  RESOLVER="${SCRIPT_DIR}/resolve-plan-dir.sh"
23
24
 
25
+ slug_is_valid() {
26
+ case "$1" in
27
+ '') return 1 ;;
28
+ *[!A-Za-z0-9._-]*) return 1 ;;
29
+ [A-Za-z0-9_]*) return 0 ;;
30
+ esac
31
+ return 1
32
+ }
33
+
34
+ resolve_from_slug_cwd() {
35
+ slug_cwd="$(pwd -P 2>/dev/null)" || return 1
36
+ planning_dir="${slug_cwd%/*}"
37
+ [ "${planning_dir##*/}" = ".planning" ] || return 1
38
+ plan_id="${slug_cwd##*/}"
39
+ slug_is_valid "${plan_id}" || return 1
40
+ [ -f "${slug_cwd}/task_plan.md" ] || return 1
41
+ printf "%s\n" "${slug_cwd}/task_plan.md"
42
+ }
43
+
24
44
  resolve_plan_file() {
25
45
  plan_dir=""
26
46
  if [ -f "${RESOLVER}" ]; then
@@ -30,6 +50,22 @@ resolve_plan_file() {
30
50
  printf "%s\n" "${plan_dir}/task_plan.md"
31
51
  return 0
32
52
  fi
53
+
54
+ # Explicit selectors are bindings, not hints. If the shared resolver
55
+ # rejected one, do not attest a different plan through a cwd fallback.
56
+ if [ -n "${PWF_PLAN_ROOT:-}" ] || [ -n "${PLAN_ID:-}" ]; then
57
+ return 1
58
+ fi
59
+
60
+ # An absolute script path does not change the invoking shell's cwd. When
61
+ # that cwd is a slug plan directory, keep slug-mode storage semantics
62
+ # instead of misclassifying its task_plan.md as a legacy root plan.
63
+ slug_plan_file="$(resolve_from_slug_cwd)" || slug_plan_file=""
64
+ if [ -n "${slug_plan_file}" ]; then
65
+ printf "%s\n" "${slug_plan_file}"
66
+ return 0
67
+ fi
68
+
33
69
  if [ -f "./task_plan.md" ]; then
34
70
  printf "%s\n" "./task_plan.md"
35
71
  return 0
@@ -24,6 +24,21 @@
24
24
 
25
25
  set -e
26
26
 
27
+ usage() {
28
+ cat << 'EOF'
29
+ Usage: init-session.sh [OPTIONS] [PROJECT NAME]
30
+
31
+ Initialize task_plan.md, findings.md, and progress.md for a planning session.
32
+
33
+ Options:
34
+ -t, --template TYPE Use the default or analytics template.
35
+ --plan-dir Create an isolated plan directory without a name.
36
+ --autonomous Enable autonomous mode and plan attestation.
37
+ --gated Enable autonomous mode with the completion gate.
38
+ -h, --help Print this help and exit without changing files.
39
+ EOF
40
+ }
41
+
27
42
  TEMPLATE="default"
28
43
  PROJECT_NAME=""
29
44
  USE_PLAN_DIR=0
@@ -51,6 +66,10 @@ while [ $# -gt 0 ]; do
51
66
  MODE="gated"
52
67
  shift
53
68
  ;;
69
+ --help|-h)
70
+ usage
71
+ exit 0
72
+ ;;
54
73
  *)
55
74
  if [ -z "$PROJECT_NAME" ]; then
56
75
  PROJECT_NAME="$1"