From 137afd7132aea0df9bbfccf6840c1defed799acc Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 14:31:20 +0100 Subject: [PATCH 1/7] fix: hooks write and read a milestone's files where it already lives (#70) yt_artifact_dir and yt_artifact_path in hooks/lib/git-ctx.sh name the directory that holds a milestone's roadmap or files (flat first, then milestones/, milestones/*/, backlog/, backlog/*/), else the flat one. post-tool-use-bash and task-completed write their summaries there; stop, pre-tool-use-edit, session-start, task-created and teammate-idle read there. ytstack-risk counts M### files in those directories as process records. Co-Authored-By: Claude Opus 5.5 --- bin/ytstack-risk | 3 +++ docs/ux/review-policy-format.md | 2 +- hooks/lib/git-ctx.sh | 36 +++++++++++++++++++++++++++++++- hooks/post-tool-use-bash | 3 ++- hooks/pre-tool-use-edit | 2 +- hooks/session-start | 9 ++++---- hooks/stop | 2 +- hooks/task-completed | 5 +++-- hooks/task-created | 4 ++-- hooks/teammate-idle | 2 +- tests/git-ctx.test.sh | 24 +++++++++++++++++++++ tests/hooks-stop.test.sh | 6 ++++++ tests/hooks-worktree.test.sh | 16 ++++++++++++++ tests/post-tool-use-bash.test.sh | 9 ++++++++ tests/ytstack-risk.test.sh | 2 ++ 15 files changed, 111 insertions(+), 14 deletions(-) diff --git a/bin/ytstack-risk b/bin/ytstack-risk index 494202f8..7ab20b21 100755 --- a/bin/ytstack-risk +++ b/bin/ytstack-risk @@ -397,6 +397,9 @@ is_record() { .ytstack/M[0-9][0-9][0-9]-*-PLAN.md|.ytstack/M[0-9][0-9][0-9]-*-SUMMARY.md) return 0 ;; .ytstack/M[0-9][0-9][0-9]-CONTEXT.md|.ytstack/M[0-9][0-9][0-9]-ROADMAP.md|.ytstack/M[0-9][0-9][0-9]-SUMMARY.md) return 0 ;; esac + # The same files in the directory a milestone lives in (issue #70): judged by name. + case "$1" in .ytstack/milestones/*/M[0-9][0-9][0-9]-*|.ytstack/milestones/M[0-9][0-9][0-9]-*|.ytstack/backlog/*/M[0-9][0-9][0-9]-*|.ytstack/backlog/M[0-9][0-9][0-9]-*) + is_record ".ytstack/${1##*/}"; return ;; esac return 1 } diff --git a/docs/ux/review-policy-format.md b/docs/ux/review-policy-format.md index cf74af53..b0add60f 100644 --- a/docs/ux/review-policy-format.md +++ b/docs/ux/review-policy-format.md @@ -46,7 +46,7 @@ There is one `reason:` line per path and rule that raised the floor. A rule name The built-in lists cannot be shortened by the project, only extended. `REVIEW.md` is itself under "Always a person", so the policy cannot be relaxed on the route it governs. -**Process records** are exempt from the coverage rule and do not count towards the size. They are, under `.ytstack/`: the files `M###-CONTEXT.md`, `M###-ROADMAP.md`, `M###-...-PLAN.md` and `M###-...-SUMMARY.md`, `STATE.md`, `LANES.md`, `KNOWLEDGE.md`, `ROADMAP.md`, `quick/` and `questions/`; and the evidence directory (`evidence_dir`, when it is a path inside the repository). Every other rule applies to them. +**Process records** are exempt from the coverage rule and do not count towards the size. They are, under `.ytstack/`: the files `M###-CONTEXT.md`, `M###-ROADMAP.md`, `M###-...-PLAN.md` and `M###-...-SUMMARY.md` (also inside `milestones/` and `backlog/` and one directory below them, where a milestone lives once its files were moved), `STATE.md`, `LANES.md`, `KNOWLEDGE.md`, `ROADMAP.md`, `quick/` and `questions/`; and the evidence directory (`evidence_dir`, when it is a path inside the repository). Every other rule applies to them. **Where the policy is read.** The script reads the policy at the base commit, never from the working tree: the `paths` and `auto_merge` of the area files, `REVIEW.md` and `evidence_dir`. A change to one of them is itself `person`, so the base and the head agree whenever the floor is not `person`, and an edit that is not committed changes nothing. A `REVIEW.md` that does not parse at the base sends every change to a person. A repository without area files has no covered path: the floor is `person` with one reason for all paths. diff --git a/hooks/lib/git-ctx.sh b/hooks/lib/git-ctx.sh index 8498424d..4c90111a 100644 --- a/hooks/lib/git-ctx.sh +++ b/hooks/lib/git-ctx.sh @@ -623,7 +623,7 @@ yt_brownfield_signals() { # line, from the flat layout and the layouts consumers already use: # / milestones/ milestones/*/ decisions/ # backlog/ backlog/*/ quick/ -# Writing stays flat; only reading tolerates the alternatives. +# Writing follows the directory a milestone already lives in: yt_artifact_dir. yt_find_artifacts() { local ytd="$1" pat="$2" d [ -d "$ytd" ] || return 0 @@ -640,6 +640,40 @@ yt_find_artifacts() { return 0 } +# yt_artifact_dir -> the directory the artifacts of live in +# and new ones go to (issue #70). is an artifact id or its prefix +# (M005, M005-S02, M005-S02-T01, a backlog prefix); only the part before the +# first `-` counts. First the directory holding -ROADMAP.md, then the +# one holding any -* file, searched in , milestones/, +# milestones/*/, backlog/, backlog/*/ (flat first); else . Nothing is +# moved: a milestone that lives flat stays flat. +yt_artifact_dir() { + local ytd="$1" p="${2%%-*}" d f + [ -n "$ytd" ] && [ -n "$p" ] && [ -d "$ytd" ] || { printf '%s\n' "$ytd"; return 0; } + for f in "$p-ROADMAP.md" "$p-*"; do + for d in "$ytd" "$ytd"/milestones "$ytd"/milestones/* "$ytd"/backlog "$ytd"/backlog/*; do + [ -d "$d" ] || continue + # shellcheck disable=SC2086 # $f is a glob on purpose + set -- "$d"/$f + [ -e "$1" ] && { printf '%s\n' "$d"; return 0; } + done + done + printf '%s\n' "$ytd" + return 0 +} + +# yt_artifact_path -> where that artifact is read from +# and written to: the file in yt_artifact_dir if it is there, else the newest +# one yt_find_artifacts finds, else / (new file). +yt_artifact_path() { + local ytd="$1" name="$2" d hit + d=$(yt_artifact_dir "$ytd" "$name") + [ -e "$d/$name" ] && { printf '%s\n' "$d/$name"; return 0; } + hit=$(yt_find_artifacts "$ytd" "$name" | head -1) + printf '%s\n' "${hit:-$d/$name}" + return 0 +} + # ---- standing instructions, one file per entry (issue #57) -------------------- # yt_standing -> the standing entries in force, newest first, one per # line: TAB TAB . Entries live in diff --git a/hooks/post-tool-use-bash b/hooks/post-tool-use-bash index bd76c884..2e2fea2f 100644 --- a/hooks/post-tool-use-bash +++ b/hooks/post-tool-use-bash @@ -65,7 +65,8 @@ if ! [[ "$SUBJECT" =~ $PATTERN ]]; then exit 0 fi -SUMMARY_FILE="$YT_DIR/$TASK_REF-SUMMARY.md" +# The milestone's directory: flat, or milestones/M###/ once it lives there (#70). +SUMMARY_FILE=$(yt_artifact_path "$YT_DIR" "$TASK_REF-SUMMARY.md") [ -f "$SUMMARY_FILE" ] && exit 0 # stub-once COMMIT_SHA=$(git -C "$YT_TOPLEVEL" rev-parse --short HEAD 2>/dev/null || echo unknown) diff --git a/hooks/pre-tool-use-edit b/hooks/pre-tool-use-edit index d3828ca1..3fe2b2ca 100644 --- a/hooks/pre-tool-use-edit +++ b/hooks/pre-tool-use-edit @@ -76,7 +76,7 @@ ACTIVE_TASK=$(sed -n 's/^active_task: *//p' "$STATE_FILE" | head -1) SCOPE_DRIFT=no if [ -n "$ACTIVE_TASK" ] && [ "$ACTIVE_TASK" != "none" ]; then - TASK_PLAN="$YT_DIR/$CURRENT_MILESTONE-$ACTIVE_SLICE-$ACTIVE_TASK-PLAN.md" + TASK_PLAN=$(yt_artifact_path "$YT_DIR" "$CURRENT_MILESTONE-$ACTIVE_SLICE-$ACTIVE_TASK-PLAN.md") if [ -f "$TASK_PLAN" ]; then # Check if the target path appears in the Files section if ! grep -qF "$REL_PATH" "$TASK_PLAN" 2>/dev/null && ! grep -qF "$(basename "$REL_PATH")" "$TASK_PLAN" 2>/dev/null; then diff --git a/hooks/session-start b/hooks/session-start index 59670166..15061ac0 100644 --- a/hooks/session-start +++ b/hooks/session-start @@ -131,11 +131,12 @@ NEXT_ACTION=$(awk '/^## Next action/{flag=1; next} /^## /{flag=0} flag' "$STATE_ # Lifecycle hints (M019-S03): a closed slice or milestone has a documented next step. LIFECYCLE_LINES="" if [ "${CURRENT_MILESTONE:-none}" != none ]; then - _rm="$YT_DIR/$CURRENT_MILESTONE-ROADMAP.md" - if [ -f "$_rm" ] && [ "$(sed -n 's/^status: *//p' "$_rm" | head -1)" = done ] && [ ! -f "$YT_DIR/$CURRENT_MILESTONE-RETRO.md" ]; then + _rm=$(yt_artifact_path "$YT_DIR" "$CURRENT_MILESTONE-ROADMAP.md") + _sp=$(yt_artifact_path "$YT_DIR" "$CURRENT_MILESTONE-${ACTIVE_SLICE:-none}-PLAN.md") + if [ -f "$_rm" ] && [ "$(sed -n 's/^status: *//p' "$_rm" | head -1)" = done ] && [ ! -f "$(yt_artifact_path "$YT_DIR" "$CURRENT_MILESTONE-RETRO.md")" ]; then LIFECYCLE_LINES="Milestone $CURRENT_MILESTONE is done and has no retro: ytstack:retro, then ytstack:document-release for the version, then ytstack:plan-milestone." - elif [ "${ACTIVE_SLICE:-none}" != none ] && [ -f "$YT_DIR/$CURRENT_MILESTONE-$ACTIVE_SLICE-PLAN.md" ] \ - && [ "$(sed -n 's/^status: *//p' "$YT_DIR/$CURRENT_MILESTONE-$ACTIVE_SLICE-PLAN.md" | head -1)" = done ]; then + elif [ "${ACTIVE_SLICE:-none}" != none ] && [ -f "$_sp" ] \ + && [ "$(sed -n 's/^status: *//p' "$_sp" | head -1)" = done ]; then LIFECYCLE_LINES="Slice $ACTIVE_SLICE is done: ytstack:reassess-roadmap first; then ytstack:finish-branch (merge / PR / keep) or ytstack:ship (release flow) for the branch." fi fi diff --git a/hooks/stop b/hooks/stop index cc06df42..d0186fad 100644 --- a/hooks/stop +++ b/hooks/stop @@ -36,7 +36,7 @@ case "$T" in ""|none|all) exit 0 ;; esac case "$S" in ""|none|all) exit 0 ;; esac case "$M" in ""|none) exit 0 ;; esac -SUMMARY="$YT_DIR/$M-$S-$T-SUMMARY.md" +SUMMARY=$(yt_artifact_path "$YT_DIR" "$M-$S-$T-SUMMARY.md") MSG="" if [ ! -f "$SUMMARY" ]; then MSG="ytstack: $M-$S-$T is still the active task and has no summary. If the work is done, run /ytstack:summarize-task; if you are pausing, /ytstack:handoff-session keeps the thread." diff --git a/hooks/task-completed b/hooks/task-completed index 3d7608c4..17870e75 100644 --- a/hooks/task-completed +++ b/hooks/task-completed @@ -40,7 +40,8 @@ if [ -z "$TASK_ID" ]; then exit 0 fi -SUMMARY_FILE="$YT_DIR/$TASK_ID-SUMMARY.md" +# The milestone's directory: flat, or milestones/M###/ once it lives there (#70). +SUMMARY_FILE=$(yt_artifact_path "$YT_DIR" "$TASK_ID-SUMMARY.md") # Don't overwrite an existing summary if [ -f "$SUMMARY_FILE" ]; then @@ -89,7 +90,7 @@ Task was marked complete by the Agent Teams lead or by self-claim. Check \`~/.cl EOF # Also flip the slice-plan checkbox if we can -SLICE_PLAN="$YT_DIR/$MILESTONE-$SLICE-PLAN.md" +SLICE_PLAN=$(yt_artifact_path "$YT_DIR" "$MILESTONE-$SLICE-PLAN.md") if [ -f "$SLICE_PLAN" ]; then if sed --version >/dev/null 2>&1; then sed -i "s/^- \[ \] $TASK /- [x] $TASK /" "$SLICE_PLAN" 2>/dev/null || true diff --git a/hooks/task-created b/hooks/task-created index 09d2cc0b..89fd702e 100644 --- a/hooks/task-created +++ b/hooks/task-created @@ -43,10 +43,10 @@ fi # Build the corpus: all slice-plans for the current milestone CORPUS_FILES="" -for plan in "$YT_DIR"/$CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md; do +for plan in "$(yt_artifact_dir "$YT_DIR" "$CURRENT_MILESTONE")"/$CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md; do [ -f "$plan" ] && CORPUS_FILES="$CORPUS_FILES $plan" done -CORPUS_FILES="$CORPUS_FILES $YT_DIR/$CURRENT_MILESTONE-ROADMAP.md" +CORPUS_FILES="$CORPUS_FILES $(yt_artifact_path "$YT_DIR" "$CURRENT_MILESTONE-ROADMAP.md")" # Simple heuristic: extract candidate file paths from the task text. # If the task mentions a file that's not listed in any slice-plan's Files diff --git a/hooks/teammate-idle b/hooks/teammate-idle index 19ea4286..d4a3f02d 100644 --- a/hooks/teammate-idle +++ b/hooks/teammate-idle @@ -29,7 +29,7 @@ CURRENT_MILESTONE=$(sed -n 's/^current_milestone: *//p' "$STATE_FILE" | head -1) # Count unfinished tasks across all slice-plans for this milestone OPEN_TASK_COUNT=0 -for plan in "$YT_DIR"/$CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md; do +for plan in "$(yt_artifact_dir "$YT_DIR" "$CURRENT_MILESTONE")"/$CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md; do [ -f "$plan" ] || continue count=$(grep -c '^- \[ \] T[0-9][0-9]' "$plan" 2>/dev/null || echo 0) OPEN_TASK_COUNT=$((OPEN_TASK_COUNT + count)) diff --git a/tests/git-ctx.test.sh b/tests/git-ctx.test.sh index 9b98e063..486568a3 100644 --- a/tests/git-ctx.test.sh +++ b/tests/git-ctx.test.sh @@ -373,6 +373,30 @@ eq "find: backlog subdirs" 1 "$(fa "$FA" 'item.md' | grep -c .)" eq "find: specific plan missing -> empty" "" "$(fa "$FA" 'M009-S01-T01-PLAN.md')" eq "find: missing dir -> empty" "" "$(fa "$TMP/nope" '*.md')" +# ---- artifact write directory follows the milestone's directory (issue #70) ---- +echo "# artifact dir" +AD="$TMP/ad/.ytstack"; mkdir -p "$AD/milestones/M001" "$AD/milestones/M002" "$AD/backlog/OPS" "$AD/milestones/M004" +printf 'r\n' > "$AD/M003-ROADMAP.md" # flat milestone +printf 'r\n' > "$AD/milestones/M001/M001-ROADMAP.md" # moved milestone +printf 'p\n' > "$AD/milestones/M001/M001-S01-T01-PLAN.md" +printf 'p\n' > "$AD/M001-S01-T02-PLAN.md" # landed flat before the fix +printf 's\n' > "$AD/milestones/M002/M002-S01-PLAN.md" # moved, no roadmap +printf 'b\n' > "$AD/backlog/OPS/OPS-001.md" # backlog prefix dir +ad() { ( . "$LIB"; yt_artifact_dir "$1" "$2" ); } +ap() { ( . "$LIB"; yt_artifact_path "$1" "$2" ); } +eq "artifact dir: roadmap in milestones/M001 -> there" "$AD/milestones/M001" "$(ad "$AD" M001)" +eq "artifact dir: a task id counts by its milestone" "$AD/milestones/M001" "$(ad "$AD" M001-S01-T03)" +eq "artifact dir: no roadmap, a moved file -> its directory" "$AD/milestones/M002" "$(ad "$AD" M002-S02)" +eq "artifact dir: flat milestone stays flat" "$AD" "$(ad "$AD" M003-S01)" +eq "artifact dir: empty milestone dir does not count" "$AD" "$(ad "$AD" M004)" +eq "artifact dir: unknown milestone -> flat" "$AD" "$(ad "$AD" M009)" +eq "artifact dir: backlog prefix -> backlog/OPS" "$AD/backlog/OPS" "$(ad "$AD" OPS-002)" +eq "artifact dir: missing yt dir -> printed as given" "$TMP/nope" "$(ad "$TMP/nope" M001)" +eq "artifact path: new file of a moved milestone" "$AD/milestones/M001/M001-S01-T03-PLAN.md" "$(ap "$AD" M001-S01-T03-PLAN.md)" +eq "artifact path: existing file in the milestone dir" "$AD/milestones/M001/M001-S01-T01-PLAN.md" "$(ap "$AD" M001-S01-T01-PLAN.md)" +eq "artifact path: existing file elsewhere is still found" "$AD/M001-S01-T02-PLAN.md" "$(ap "$AD" M001-S01-T02-PLAN.md)" +eq "artifact path: flat milestone -> flat" "$AD/M003-S01-PLAN.md" "$(ap "$AD" M003-S01-PLAN.md)" + # ---- yt_standing: one file per standing instruction (issue #57) ---- echo "# standing entries" ST="$TMP/st/.ytstack"; mkdir -p "$ST/standing" diff --git a/tests/hooks-stop.test.sh b/tests/hooks-stop.test.sh index 0afcceb3..360c5709 100644 --- a/tests/hooks-stop.test.sh +++ b/tests/hooks-stop.test.sh @@ -51,6 +51,12 @@ printf -- '---\nclosed: 2026-11-07T00:00:00Z\n---\n' > "$MAIN/.ytstack/M042-S03- OUT=$(fire "$MAIN"); eq "real summary -> silent" "" "$OUT" rm -f "$MAIN/.ytstack/M042-S03-T07-SUMMARY.md" +echo "# summary in milestones/M042/ (#70)" +mkdir -p "$MAIN/.ytstack/milestones/M042" +printf -- '---\nclosed: 2026-11-07T00:00:00Z\n---\n' > "$MAIN/.ytstack/milestones/M042/M042-S03-T07-SUMMARY.md" +OUT=$(fire "$MAIN"); eq "moved summary -> silent" "" "$OUT" +rm -rf "$MAIN/.ytstack/milestones" + echo "# guards" OUT=$(fire "$MAIN" ',"stop_hook_active":true'); eq "stop_hook_active -> silent" "" "$OUT" printf 'current_milestone: M042\nactive_slice: none\nactive_task: none\n' > "$MAIN/.ytstack/STATE.md" diff --git a/tests/hooks-worktree.test.sh b/tests/hooks-worktree.test.sh index c8fcf533..9a0974af 100644 --- a/tests/hooks-worktree.test.sh +++ b/tests/hooks-worktree.test.sh @@ -121,6 +121,22 @@ eq "repeat: no new files in main" "$MAIN_FILES" "$(files_in "$MAIN")" eq "repeat: main HANDOFF.md still intact" "$H_SHA" "$(shasum -a 256 "$MAIN/.ytstack/HANDOFF.md" | cut -c1-16)" eq "repeat: journal appended, not duplicated elsewhere" 2 "$(cat "$PD/repos/$KW/sessions/sc/session.jsonl" | wc -l | tr -d ' ')" +# ---- (d) milestone moved to milestones/M050/ (#70) --------------------------- +echo "# (d) moved milestone" +MV="$TMP/moved"; mkdir -p "$MV/.ytstack/milestones/M050" +( cd "$MV" || exit 2; git init -q && git config user.email t@t.t && git config user.name t + printf 'current_milestone: M050\nactive_slice: S01\nactive_task: T01\n' > .ytstack/STATE.md + printf -- '---\nmilestone: M050\n---\n- [ ] S01 -- x\n' > .ytstack/milestones/M050/M050-ROADMAP.md + printf -- '---\nslice: S01\n---\n- [ ] T01 -- one (src/a.ts)\n- [ ] T02 -- two\n' > .ytstack/milestones/M050/M050-S01-PLAN.md + echo seed > f.txt; git add -A; git commit -qm seed ) >/dev/null 2>&1 || { echo FATAL moved fixture; exit 2; } +SESSION=sd +fire task-completed "$MV" "$MV" ',"tool_input":{"subject":"M050-S01-T02 -- two"}' +[ -f "$MV/.ytstack/milestones/M050/M050-S01-T02-SUMMARY.md" ] && ok "d: task-completed writes the summary into milestones/M050/" || bad "d: summary in milestones/M050/" +[ -e "$MV/.ytstack/M050-S01-T02-SUMMARY.md" ] && bad "d: no flat summary" || ok "d: no flat summary" +grep -F -- '- [x] T02 -- two' >/dev/null "$MV/.ytstack/milestones/M050/M050-S01-PLAN.md" && ok "d: checkbox ticked in the moved slice plan" || bad "d: checkbox ticked in the moved slice plan" +fire teammate-idle "$MV" "$MV" '' +case "$(cat "$TMP/err.teammate-idle")" in *"1 task(s) still open in milestone M050"*) ok "d: teammate-idle counts the moved slice plan";; *) bad "d: teammate-idle counts the moved slice plan" "$(cat "$TMP/err.teammate-idle")";; esac + echo echo "$PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ] diff --git a/tests/post-tool-use-bash.test.sh b/tests/post-tool-use-bash.test.sh index e118e839..62d7502d 100644 --- a/tests/post-tool-use-bash.test.sh +++ b/tests/post-tool-use-bash.test.sh @@ -175,6 +175,15 @@ printf '{"tool_input":{"command":"git commit -m x"},"tool_response":{"exit_code" [ -f "$R14/$SUMREL" ] && ok "T14 no cwd in payload -> falls back to hook PWD" \ || bad "T14 PWD fallback failed" +# --- T15: milestone moved to milestones/M999/ -> stub lands there (#70) ------ +R15=$(new_repo) +in_fixture "$R15"; mkdir -p "$R15/.ytstack/milestones/M999"; printf 'r\n' > "$R15/.ytstack/milestones/M999/M999-ROADMAP.md" +commit_in "$R15" m "M999-S01-T01: add m" +fire "$R15" 'git commit -m "M999-S01-T01: add m"' 0 +[ -f "$R15/.ytstack/milestones/M999/M999-S01-T01-SUMMARY.md" ] && ok "T15 moved milestone -> stub in milestones/M999/" \ + || bad "T15 stub not in the milestone's directory" +[ ! -f "$R15/$SUMREL" ] && ok "T15 no flat stub beside the moved milestone" || bad "T15 stub written flat" + echo echo "RESULT: $PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ] diff --git a/tests/ytstack-risk.test.sh b/tests/ytstack-risk.test.sh index 433f3e07..f68a2ea2 100644 --- a/tests/ytstack-risk.test.sh +++ b/tests/ytstack-risk.test.sh @@ -229,6 +229,8 @@ change "$R" files21 'for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 normal "21 changed files are over the limit" "reason: size -- never low: 21 changed lines in 21 files" change "$R" bigrecord 'echo b >> src/auth/login.sh; awk "BEGIN { for (i = 0; i < 500; i++) print \"l\" }" > .ytstack/M001-S01-T01-PLAN.md'; fl eq "process records do not count towards the size" "floor: low" "$(line floor)" +change "$R" bigrecord-moved 'echo b >> src/auth/login.sh; mkdir -p .ytstack/milestones/M001 && awk "BEGIN { for (i = 0; i < 500; i++) print \"l\" }" > .ytstack/milestones/M001/M001-S01-T01-PLAN.md'; fl +eq "a record in milestones/M###/ is a process record too (#70)" "floor: low" "$(line floor)" change "$R" binary 'printf "\0\1\2\3" > src/auth/blob.bin'; fl eq "a binary file is one file and no lines" "floor: low" "$(line floor)" From 7cf4eb6b2927a39c35bfc6fe7d984fe9d3e0beb7 Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 14:31:37 +0100 Subject: [PATCH 2/7] fix: skills write new artifacts into the directory their milestone lives in (#70) Preambles print ARTIFACT_DIR (fallback YT_DIR without the lib) and find the milestone's roadmap, slice and task plans and summaries through yt_artifact_path; the write steps of plan-milestone, slice-milestone, plan-task, summarize-task, the reviews and retro use ARTIFACT_DIR. plan-milestone counts moved milestones when it picks the next number. gstack-adapted skills touched (plan-ceo-review, plan-eng-review, retro, ship): bin/ytstack-gstack-diff --stat reports no upstream change for them at v1.99.4.0, so their baseline stays. Co-Authored-By: Claude Opus 5.5 --- skills/code-review/SKILL.md | 5 +- skills/finish-branch/SKILL.md | 11 +++-- skills/grill/SKILL.md | 6 ++- skills/handoff-session/SKILL.md | 8 ++-- skills/plan-ceo-review/SKILL.md | 10 ++-- skills/plan-eng-review/SKILL.md | 9 ++-- skills/plan-milestone/SKILL.md | 20 +++++--- skills/plan-task/SKILL.md | 19 +++++--- skills/reassess-roadmap/SKILL.md | 29 +++++++---- skills/retro/SKILL.md | 24 ++++++---- skills/ship/SKILL.md | 10 ++-- skills/slice-milestone/SKILL.md | 9 ++-- skills/spawn-milestone-team/SKILL.md | 11 +++-- skills/summarize-task/SKILL.md | 23 +++++---- skills/test-driven-development/SKILL.md | 5 +- .../verification-before-completion/SKILL.md | 5 +- tests/skill-preambles.test.sh | 48 +++++++++++++++++++ 17 files changed, 179 insertions(+), 73 deletions(-) diff --git a/skills/code-review/SKILL.md b/skills/code-review/SKILL.md index c079b82e..947080fe 100644 --- a/skills/code-review/SKILL.md +++ b/skills/code-review/SKILL.md @@ -2,7 +2,7 @@ name: code-review metadata: tier: task - version: 0.5.0 + version: 0.5.1 description: "Reviews the active task's commits with a fresh-context reviewer subagent and handles the feedback with technical rigor, through the vendored superpowers requesting-code-review and receiving-code-review procedures, with the task plan and commit range injected. Use after a task's commits exist and before summarize-task, before a merge or PR, or when the user says review this, code review, check my changes. Not for reviewing a plan (plan-eng-review) and not without commits for the task." allowed-tools: - Bash @@ -40,7 +40,8 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _S=$(sed -n 's/^active_slice: *//p' "$_YT_DIR/STATE.md" | head -1) _T=$(sed -n 's/^active_task: *//p' "$_YT_DIR/STATE.md" | head -1) fi -_TASK_PLAN="$_YT_DIR/$_M-$_S-$_T-PLAN.md" +# The plan lives with its milestone: flat or milestones/M###/ (issue #70) +if command -v yt_artifact_path >/dev/null 2>&1; then _TASK_PLAN=$(yt_artifact_path "$_YT_DIR" "$_M-$_S-$_T-PLAN.md"); else _TASK_PLAN="$_YT_DIR/$_M-$_S-$_T-PLAN.md"; fi # Commits of the active task (same discovery as summarize-task: task-ref pattern, branch fallback). _COMMITS=""; _COMMITS_SOURCE=none; _BASE_SHA=""; _HEAD_SHA=$(git rev-parse HEAD 2>/dev/null || echo none) if [ "$_IS_GIT" = yes ] && [ "$_T" != none ] && command -v yt_task_commits >/dev/null 2>&1; then diff --git a/skills/finish-branch/SKILL.md b/skills/finish-branch/SKILL.md index 5fcc89b3..fa7a6425 100644 --- a/skills/finish-branch/SKILL.md +++ b/skills/finish-branch/SKILL.md @@ -2,7 +2,7 @@ name: finish-branch metadata: tier: task - version: 0.1.0 + version: 0.1.1 description: "Decides how a finished branch or worktree is integrated (merge locally, push + PR, keep) through the vendored superpowers finishing-a-development-branch procedure, with ytstack's branch, worktree and task-summary state injected. Use when the slice or milestone work on a branch is done and verified, or when the user says finish the branch, merge this, open the PR, wrap up the worktree. Not before verification-before-completion passed and not for closing a task (summarize-task)." allowed-tools: - Bash @@ -40,9 +40,12 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then fi # Slice summary state: every task in the slice plan needs a non-draft summary before a branch is "done". _OPEN_TASKS=""; _DRAFT_SUMMARIES=0 -if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/$_M-$_S-PLAN.md" ]; then - for t in $(grep -oE '^- \[.\] T[0-9][0-9] --' "$_YT_DIR/$_M-$_S-PLAN.md" | grep -oE 'T[0-9][0-9]'); do - f="$_YT_DIR/$_M-$_S-$t-SUMMARY.md" +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } +_SP=$(_ap "$_M-$_S-PLAN.md") +if [ -n "$_YT_DIR" ] && [ -f "$_SP" ]; then + for t in $(grep -oE '^- \[.\] T[0-9][0-9] --' "$_SP" | grep -oE 'T[0-9][0-9]'); do + f=$(_ap "$_M-$_S-$t-SUMMARY.md") if [ ! -f "$f" ]; then _OPEN_TASKS="$_OPEN_TASKS $t" elif grep -q '^closed: draft' "$f"; then _OPEN_TASKS="$_OPEN_TASKS $t"; _DRAFT_SUMMARIES=$((_DRAFT_SUMMARIES+1)); fi done diff --git a/skills/grill/SKILL.md b/skills/grill/SKILL.md index e2f3f8cf..e933e452 100644 --- a/skills/grill/SKILL.md +++ b/skills/grill/SKILL.md @@ -2,7 +2,7 @@ name: grill metadata: tier: core - version: 0.1.0 + version: 0.1.1 description: "Relentless questioning of an idea before it becomes a milestone, through the vendored superpowers brainstorming procedure with ytstack's pitch, project one-liner and decisions injected; writes the agreed design into the milestone context. Use between office-hours and plan-milestone, when a feature request is bigger than one sentence, or when the user says grill me, poke holes in this, let's think this through, design before we plan. Not for one-sentence changes (quick-task) and not for slicing or task plans (slice-milestone, plan-task)." allowed-tools: - Bash @@ -46,7 +46,9 @@ echo "CURRENT_MILESTONE: $_M" echo "ONE_LINER: ${_ONE_LINER:-none}" echo "PITCH: $_PITCH" echo "DECISIONS_COUNT: $_DECISIONS" -echo "DESIGN_TARGET: $([ "$_M" != none ] && [ -n "$_YT_DIR" ] && echo "$_YT_DIR/$_M-CONTEXT.md" || echo "${_YT_DIR:-.}/GRILL-.md")" +# The milestone's CONTEXT lives with its milestone: flat or milestones/M###/ (issue #70) +if command -v yt_artifact_path >/dev/null 2>&1; then _CTX=$(yt_artifact_path "$_YT_DIR" "$_M-CONTEXT.md"); else _CTX="$_YT_DIR/$_M-CONTEXT.md"; fi +echo "DESIGN_TARGET: $([ "$_M" != none ] && [ -n "$_YT_DIR" ] && echo "$_CTX" || echo "${_YT_DIR:-.}/GRILL-.md")" ``` ## ytstack invocation notes diff --git a/skills/handoff-session/SKILL.md b/skills/handoff-session/SKILL.md index ed43b108..0ef47f96 100644 --- a/skills/handoff-session/SKILL.md +++ b/skills/handoff-session/SKILL.md @@ -3,7 +3,7 @@ name: handoff-session description: "Writes a hand-authored HANDOFF.md so the next session, machine or teammate continues without re-explanation. Use when the user says handoff, pause work, save context for later, or before switching machines, a long break or a deliberate context clear. Not for routine session ends (the SessionEnd hook writes an automatic handoff) and not for closing a task (summarize-task)." metadata: tier: task - version: 0.1.2 + version: 0.1.3 triggers: - handoff session - pause work @@ -67,6 +67,8 @@ echo "HAS_YTSTACK: $_HAS_YTSTACK" echo "PROJECT_NAME: $_PROJECT_NAME" echo "CURRENT_MILESTONE: $_CURRENT_MILESTONE / $_ACTIVE_SLICE / $_ACTIVE_TASK" echo "BRANCH: $_BRANCH" +# The milestone's files: flat, or the directory it already lives in (issue #70) +if command -v yt_artifact_dir >/dev/null 2>&1; then echo "ARTIFACT_DIR: $(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE")"; else echo "ARTIFACT_DIR: $_YT_DIR"; fi ``` ## Procedure @@ -153,7 +155,7 @@ Written by the user via `/ytstack:handoff-session` at {ISO_TIMESTAMP}. 1. Start a new Claude Code session in this project directory. 2. SessionStart hook will auto-inject state from `STATE.md` -- read that first. 3. Read this file (`HANDOFF.md`) for the in-flight context. For what applies now in the code you continue in, read `{YT_DIR}/spec/SPEC.md` and the area file it names; this handoff does not repeat it. -4. Check latest `{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{ACTIVE_TASK}-PLAN.md` and corresponding `-SUMMARY.md` if it exists. +4. Check latest `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{ACTIVE_TASK}-PLAN.md` and corresponding `-SUMMARY.md` if it exists. 5. Run `/ytstack:resume-session` to get a synthesized briefing. 6. Execute the "Next action" above. @@ -161,7 +163,7 @@ Written by the user via `/ytstack:handoff-session` at {ISO_TIMESTAMP}. - Full dashboard: `{YT_DIR}/STATE.md` - What applies now: `{YT_DIR}/spec/SPEC.md` (omit this line when the project has no technical spec) -- Milestone roadmap: `{YT_DIR}/{CURRENT_MILESTONE}-ROADMAP.md` +- Milestone roadmap: `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-ROADMAP.md` - Deferred items: `{YT_DIR}/REVIEW-NOTES.md` - Decision log: `{YT_DIR}/DECISIONS.md` ``` diff --git a/skills/plan-ceo-review/SKILL.md b/skills/plan-ceo-review/SKILL.md index 367da4a3..fd5b66f2 100644 --- a/skills/plan-ceo-review/SKILL.md +++ b/skills/plan-ceo-review/SKILL.md @@ -3,7 +3,7 @@ name: plan-ceo-review description: "Challenges premise, scope and ambition of a pitch or a milestone. Use right after office-hours on OFFICE-HOURS.md, or after plan-milestone and before slice-milestone on M###-CONTEXT.md and M###-ROADMAP.md; also when the user says CEO review, scope review, is this too big, is this too small. Not for technical feasibility (plan-eng-review)." metadata: tier: core - version: 1.0.2 + version: 1.0.3 upstream: "gstack v1.99.3.0 (plan-ceo-review/, commit 1d3c63c53)" allowed-tools: - Bash @@ -141,8 +141,10 @@ echo "CURRENT_MILESTONE: $_CURRENT_MILESTONE" echo "ACTIVE_SLICE: ${_ACTIVE_SLICE:-none}" # Mode detection: milestone plan first, then an office-hours pitch -_CONTEXT_FILE="$_YT_DIR/$_CURRENT_MILESTONE-CONTEXT.md" -_ROADMAP_FILE="$_YT_DIR/$_CURRENT_MILESTONE-ROADMAP.md" +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _AD="$_YT_DIR"; fi +_CONTEXT_FILE="$_AD/$_CURRENT_MILESTONE-CONTEXT.md" +_ROADMAP_FILE="$_AD/$_CURRENT_MILESTONE-ROADMAP.md" _PITCH="" if [ -f "./OFFICE-HOURS.md" ]; then _PITCH="./OFFICE-HOURS.md" @@ -151,7 +153,7 @@ elif [ -n "$_YT_DIR" ]; then _PITCH=$(ls -t "$_YT_DIR"/OFFICE-HOURS-*.md 2>/dev/null | head -1) fi if [ "$_CURRENT_MILESTONE" != "none" ] && [ -f "$_CONTEXT_FILE" ] && [ -f "$_ROADMAP_FILE" ]; then - _MODE=milestone; _REVIEW_FILE="$_YT_DIR/$_CURRENT_MILESTONE-CEO-REVIEW.md" + _MODE=milestone; _REVIEW_FILE="$_AD/$_CURRENT_MILESTONE-CEO-REVIEW.md" elif [ -n "$_PITCH" ] && [ -f "$_PITCH" ]; then _MODE=concept; _REVIEW_FILE="$_PITCH" else diff --git a/skills/plan-eng-review/SKILL.md b/skills/plan-eng-review/SKILL.md index 6507a93c..ee14524d 100644 --- a/skills/plan-eng-review/SKILL.md +++ b/skills/plan-eng-review/SKILL.md @@ -3,7 +3,7 @@ name: plan-eng-review description: "Reviews the execution approach of a pitch or a sliced milestone for feasibility, architecture, data flow, edge cases, test coverage, performance and security. Use after plan-ceo-review on a pitch, or after slice-milestone and before plan-task on M###-S##-PLAN.md; also when the user says eng review, architecture review, lock the approach. Not for scope and ambition questions (plan-ceo-review)." metadata: tier: core - version: 1.0.2 + version: 1.0.3 upstream: "gstack v1.99.3.0 (plan-eng-review/, commit 1d3c63c53)" allowed-tools: - Bash @@ -148,7 +148,9 @@ elif [ -n "$_YT_DIR" ]; then [ -z "$_PITCH" ] && [ -f "$_YT_DIR/OFFICE-HOURS.md" ] && _PITCH="$_YT_DIR/OFFICE-HOURS.md" fi if [ -n "$_SLICE_PLANS" ]; then - _MODE=milestone; _REVIEW_FILE="$_YT_DIR/$_M-ENG-REVIEW.md" + # The review goes beside the milestone's files: flat or milestones/M###/ (issue #70) + if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_M"); else _AD="$_YT_DIR"; fi + _MODE=milestone; _REVIEW_FILE="$_AD/$_M-ENG-REVIEW.md" elif [ -n "$_PITCH" ]; then _MODE=concept; _REVIEW_FILE="$_PITCH" else @@ -165,7 +167,8 @@ for _f in DECISIONS KNOWLEDGE PROJECT; do [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/$_f.md" ] && echo "$_f: $_YT_DIR/$_f.md" done if [ "$_M" != none ] && [ -n "$_YT_DIR" ]; then - for _f in "$_YT_DIR/$_M"-CONTEXT.md "$_YT_DIR/$_M"-ROADMAP.md; do + for _f in CONTEXT ROADMAP; do + if command -v yt_artifact_path >/dev/null 2>&1; then _f=$(yt_artifact_path "$_YT_DIR" "$_M-$_f.md"); else _f="$_YT_DIR/$_M-$_f.md"; fi [ -f "$_f" ] && echo "MILESTONE_DOC: $_f" done fi diff --git a/skills/plan-milestone/SKILL.md b/skills/plan-milestone/SKILL.md index 14e796c2..f2c5c8ba 100644 --- a/skills/plan-milestone/SKILL.md +++ b/skills/plan-milestone/SKILL.md @@ -3,7 +3,7 @@ name: plan-milestone description: "Defines the next milestone (goal, exit criteria, size) and writes M###-CONTEXT.md and M###-ROADMAP.md. Use after init-project or adopt-brownfield, after a milestone closed, or when the user says plan the next milestone, new milestone, define the milestone. Not for slicing (slice-milestone) and not for unvalidated greenfield ideas (office-hours first)." metadata: tier: core - version: 0.1.0 + version: 0.1.1 triggers: - plan milestone - start new milestone @@ -88,11 +88,18 @@ _HAS_YTSTACK=$([ -n "$_YT_DIR" ] && echo yes || echo no) # Next milestone number _NEXT_MILESTONE="M001" if [ -n "$_YT_DIR" ]; then - _MAX=$(ls "$_YT_DIR"/M[0-9][0-9][0-9]-*.md 2>/dev/null | sed -E 's/.*M([0-9]{3})-.*/\1/' | sort -u | tail -1) + # Count moved milestones too (milestones/M###/, backlog//; issue #70) + if command -v yt_find_artifacts >/dev/null 2>&1; then + _MAX=$(yt_find_artifacts "$_YT_DIR" 'M[0-9][0-9][0-9]-*.md' | sed -E 's|.*/M([0-9]{3})-[^/]*$|\1|' | sort -u | tail -1) + else + _MAX=$(ls "$_YT_DIR"/M[0-9][0-9][0-9]-*.md 2>/dev/null | sed -E 's/.*M([0-9]{3})-.*/\1/' | sort -u | tail -1) + fi if [ -n "$_MAX" ]; then _NEXT_MILESTONE=$(printf "M%03d" $((10#$_MAX + 1))) fi fi +# New files go flat unless files of this milestone already live in a subdirectory +if command -v yt_artifact_dir >/dev/null 2>&1; then _ARTIFACT_DIR=$(yt_artifact_dir "$_YT_DIR" "$_NEXT_MILESTONE"); else _ARTIFACT_DIR="$_YT_DIR"; fi # Project-level frontmatter _PROJECT_NAME="" @@ -118,6 +125,7 @@ echo "YT_DIR: $_YT_DIR" echo "YT_SCOPE: $_YT_SCOPE" echo "HAS_YTSTACK: $_HAS_YTSTACK" echo "NEXT_MILESTONE: $_NEXT_MILESTONE" +echo "ARTIFACT_DIR: $_ARTIFACT_DIR" echo "TRACKER: $_TRACKER" echo "YTSTACK_NON_INTERACTIVE: $_NON_INTERACTIVE" ``` @@ -181,7 +189,7 @@ Remember as `_SIZE` (value: `S`, `M`, or `L`). ### Step 6: Write `M###-CONTEXT.md` -Use Write tool. Path: `{YT_DIR}/{NEXT_MILESTONE}-CONTEXT.md`. +Use Write tool. Path: `{ARTIFACT_DIR}/{NEXT_MILESTONE}-CONTEXT.md`. ```markdown --- @@ -216,7 +224,7 @@ size: {SIZE} ### Step 7: Write `M###-ROADMAP.md` -Use Write tool. Path: `{YT_DIR}/{NEXT_MILESTONE}-ROADMAP.md`. +Use Write tool. Path: `{ARTIFACT_DIR}/{NEXT_MILESTONE}-ROADMAP.md`. Slice-count based on size: S=1, M=2-3, L=4-5. For v0.1, always seed the lower bound (S=1, M=2, L=4). User can add more during `slice-milestone`. @@ -293,8 +301,8 @@ Report: > - Slices: {SLICE_COUNT} placeholder(s) in `{NEXT_MILESTONE}-ROADMAP.md` > > Files created: -> - `{YT_DIR}/{NEXT_MILESTONE}-CONTEXT.md` -- Q/A locked -> - `{YT_DIR}/{NEXT_MILESTONE}-ROADMAP.md` -- slice skeleton +> - `{ARTIFACT_DIR}/{NEXT_MILESTONE}-CONTEXT.md` -- Q/A locked +> - `{ARTIFACT_DIR}/{NEXT_MILESTONE}-ROADMAP.md` -- slice skeleton > > STATE.md updated: `current_milestone` = {NEXT_MILESTONE}. > diff --git a/skills/plan-task/SKILL.md b/skills/plan-task/SKILL.md index 2fd0e7ef..5772c8d7 100644 --- a/skills/plan-task/SKILL.md +++ b/skills/plan-task/SKILL.md @@ -3,7 +3,7 @@ name: plan-task description: "Turns the next task of the current slice into M###-S##-T##-PLAN.md with exact files and a verification command, and sets STATE active_task. Use after slice-milestone, before executing a task, or when the user says plan the task, next task, detail the task. Not for one-sentence changes (quick-task) and not for closing a task (summarize-task)." metadata: tier: core - version: 0.3.2 + version: 0.3.3 triggers: - plan task - detail next task @@ -87,22 +87,26 @@ if [ -f "$_YT_DIR/STATE.md" ]; then _ACTIVE_SLICE=$(sed -n 's/^active_slice: *//p' "$_YT_DIR/STATE.md" | head -1) fi +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } +if command -v yt_artifact_dir >/dev/null 2>&1; then _ARTIFACT_DIR=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _ARTIFACT_DIR="$_YT_DIR"; fi + # If no active slice in STATE.md, infer the first unfinished slice from ROADMAP if [ "$_ACTIVE_SLICE" = "none" ] || [ -z "$_ACTIVE_SLICE" ]; then - ROADMAP="$_YT_DIR/$_CURRENT_MILESTONE-ROADMAP.md" + ROADMAP=$(_ap "$_CURRENT_MILESTONE-ROADMAP.md") if [ -f "$ROADMAP" ]; then _ACTIVE_SLICE=$(grep -oE '^- \[ \] S[0-9][0-9] --' "$ROADMAP" | head -1 | grep -oE 'S[0-9][0-9]') fi fi -_SLICE_PLAN="$_YT_DIR/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md" +_SLICE_PLAN=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md") # Next unplanned task = first un-elaborated task in slice-plan # (Un-elaborated = listed in slice-plan but no corresponding T##-PLAN.md file exists) _NEXT_TASK="" if [ -f "$_SLICE_PLAN" ]; then for t in $(grep -oE '^- \[ \] T[0-9][0-9] --' "$_SLICE_PLAN" | grep -oE 'T[0-9][0-9]'); do - _TASK_FILE="$_YT_DIR/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-$t-PLAN.md" + _TASK_FILE=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-$t-PLAN.md") if [ ! -f "$_TASK_FILE" ]; then _NEXT_TASK="$t" break @@ -115,6 +119,7 @@ echo "YTSTACK_NON_INTERACTIVE: $_NON_INTERACTIVE" echo "CURRENT_MILESTONE: $_CURRENT_MILESTONE" echo "ACTIVE_SLICE: $_ACTIVE_SLICE" echo "SLICE_PLAN: $_SLICE_PLAN" +echo "ARTIFACT_DIR: $_ARTIFACT_DIR" echo "NEXT_TASK: ${_NEXT_TASK:-none}" echo "HAS_SPEC: $([ -f "$_YT_DIR/spec/SPEC.md" ] && echo yes || echo no)" echo "SPEC_TOOL: ${CLAUDE_SKILL_DIR}/../../bin/ytstack-spec" @@ -231,6 +236,8 @@ If A: proceed. ### Step 9: Write `M###-S##-T##-PLAN.md` +Use Write. Path: `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{NEXT_TASK}-PLAN.md`. `ARTIFACT_DIR` is `.ytstack/` itself, or `milestones/M###/` (or a `backlog/` subdirectory) when the milestone's files already live there; never move existing files. + Write the `**Blocked by:**` line only when this task cannot start without the result of another task of the slice (`T01`, or `T01, T03`); the order of the task list alone is not a reason, and without such a task the line is left out. ```markdown @@ -295,7 +302,7 @@ Bump `last_updated` regardless. Update Status line: `**Status:** {CURRENT_MILESTONE} / {ACTIVE_SLICE} / {NEXT_TASK} planned -- ready to execute.` -**Milestone state (M018):** if `{CURRENT_MILESTONE}-ROADMAP.md` still says `status: planned`, flip it to `status: in-progress` (Edit) and mirror the global `ROADMAP.md` row -- the first planned task is where work starts. States are the enum in `docs/ux/skill-structure.md` ("Artifact states"). +**Milestone state (M018):** if `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-ROADMAP.md` still says `status: planned`, flip it to `status: in-progress` (Edit) and mirror the global `ROADMAP.md` row -- the first planned task is where work starts. States are the enum in `docs/ux/skill-structure.md` ("Artifact states"). ### Step 11: Report + return @@ -303,7 +310,7 @@ Report: > Task **{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{NEXT_TASK}** planned. > -> File: `{SLICE_PLAN_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{NEXT_TASK}-PLAN.md` +> File: `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{NEXT_TASK}-PLAN.md` > > Spec impact: {SPEC_IMPACT} > diff --git a/skills/reassess-roadmap/SKILL.md b/skills/reassess-roadmap/SKILL.md index 785687d3..b00ca08e 100644 --- a/skills/reassess-roadmap/SKILL.md +++ b/skills/reassess-roadmap/SKILL.md @@ -3,7 +3,7 @@ name: reassess-roadmap description: "Checks at a slice boundary whether the milestone roadmap still fits reality: deviations from the summaries, gates that only a person can close or that have lapsed, work that repeats without advancing, stale milestones to mark dropped or shipped-informally, slices to add, split, reorder or remove. Use after summarize-task closed the last task of a slice, or when the user says reassess, review the roadmap, does the plan still hold. Not mid-slice and not for task detail (plan-task)." metadata: tier: task - version: 0.3.0 + version: 0.3.1 triggers: - reassess roadmap - review milestone plan @@ -76,8 +76,11 @@ if [ -f "$_YT_DIR/STATE.md" ]; then _TRACKER=${_TRACKER:-none} fi +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _AD="$_YT_DIR"; fi + # Determine if the current slice is complete -_SLICE_PLAN="$_YT_DIR/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md" +_SLICE_PLAN="$_AD/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md" _SLICE_COMPLETE=no if [ -f "$_SLICE_PLAN" ]; then # Open TASK lines only: an open gate (`- [ ] G01 --`) does not keep a slice @@ -89,7 +92,8 @@ fi # Stale milestones (M018): planned/in-progress roadmaps with no summaries and no file newer than 14 days _STALE_MILESTONES="" -for _rm in "$_YT_DIR"/M[0-9][0-9][0-9]-ROADMAP.md; do +if command -v yt_find_artifacts >/dev/null 2>&1; then _RMS=$(yt_find_artifacts "$_YT_DIR" 'M[0-9][0-9][0-9]-ROADMAP.md'); else _RMS=$(ls "$_YT_DIR"/M[0-9][0-9][0-9]-ROADMAP.md 2>/dev/null); fi +while IFS= read -r _rm; do [ -f "$_rm" ] || continue _m=$(basename "$_rm" -ROADMAP.md) _st=$(sed -n 's/^status: *//p' "$_rm" | head -1) @@ -99,15 +103,18 @@ for _rm in "$_YT_DIR"/M[0-9][0-9][0-9]-ROADMAP.md; do else [ -n "$(ls "$_YT_DIR"/$_m-*SUMMARY.md 2>/dev/null)" ] && continue fi - [ -n "$(find "$_YT_DIR" -maxdepth 1 -name "$_m-*.md" -mtime -14 2>/dev/null)" ] && continue + [ -n "$(find "$(dirname "$_rm")" -maxdepth 1 -name "$_m-*.md" -mtime -14 2>/dev/null)" ] && continue _STALE_MILESTONES="${_STALE_MILESTONES:+$_STALE_MILESTONES }$_m" -done +done <<_RMS_ +$_RMS +_RMS_ echo "HAS_YTSTACK: $_HAS_YTSTACK" echo "YTSTACK_NON_INTERACTIVE: $_NON_INTERACTIVE" echo "CURRENT_MILESTONE: $_CURRENT_MILESTONE" echo "ACTIVE_SLICE: $_ACTIVE_SLICE" echo "SLICE_COMPLETE: $_SLICE_COMPLETE" +echo "ARTIFACT_DIR: $_AD" echo "STALE_MILESTONES: ${_STALE_MILESTONES:-none}" echo "TRACKER: $_TRACKER" # Technical spec (M022): areas whose code moved on without their description. @@ -119,24 +126,24 @@ echo "SPEC_DRIFT_END" # and the two progress numbers (closed by work, accepted). _GATE_RE='^- \[ \] G[0-9]+ --' echo "OPEN_GATES_BEGIN" -grep -Hn -E "$_GATE_RE" "$_YT_DIR"/"$_CURRENT_MILESTONE"-*PLAN.md 2>/dev/null | sed "s|^$_YT_DIR/||" +grep -Hn -E "$_GATE_RE" "$_AD"/"$_CURRENT_MILESTONE"-*PLAN.md 2>/dev/null | sed "s|^$_YT_DIR/||" echo "OPEN_GATES_END" echo "REVIEW_ROUNDS_BEGIN" -for _p in "$_YT_DIR"/"$_CURRENT_MILESTONE-$_ACTIVE_SLICE"-T[0-9][0-9]-PLAN.md; do +for _p in "$_AD"/"$_CURRENT_MILESTONE-$_ACTIVE_SLICE"-T[0-9][0-9]-PLAN.md; do [ -f "$_p" ] || continue _r=$(grep -c -E '^- Round [0-9]+:' "$_p" 2>/dev/null); _r=${_r:-0} [ "$_r" -ge 3 ] && echo "$(basename "$_p" -PLAN.md): $_r review rounds" done echo "REVIEW_ROUNDS_END" _SL_TOTAL=0; _SL_WORK=0; _SL_ACC=0 -[ -f "$_YT_DIR/$_CURRENT_MILESTONE-ROADMAP.md" ] && _SL_TOTAL=$(grep -c -E '^- \[.\] S[0-9][0-9] --' "$_YT_DIR/$_CURRENT_MILESTONE-ROADMAP.md" 2>/dev/null) -for _sp in "$_YT_DIR"/"$_CURRENT_MILESTONE"-S[0-9][0-9]-PLAN.md; do +[ -f "$_AD/$_CURRENT_MILESTONE-ROADMAP.md" ] && _SL_TOTAL=$(grep -c -E '^- \[.\] S[0-9][0-9] --' "$_AD/$_CURRENT_MILESTONE-ROADMAP.md" 2>/dev/null) +for _sp in "$_AD"/"$_CURRENT_MILESTONE"-S[0-9][0-9]-PLAN.md; do [ -f "$_sp" ] || continue grep -q '^- \[ \] T[0-9]' "$_sp" && continue grep -q '^- \[[xX]\] T[0-9]' "$_sp" || continue _SL_WORK=$((_SL_WORK + 1)) _s=$(basename "$_sp" -PLAN.md) - cat "$_sp" "$_YT_DIR"/"$_s"-T[0-9][0-9]-PLAN.md 2>/dev/null | grep -q -E "$_GATE_RE" || _SL_ACC=$((_SL_ACC + 1)) + cat "$_sp" "$_AD"/"$_s"-T[0-9][0-9]-PLAN.md 2>/dev/null | grep -q -E "$_GATE_RE" || _SL_ACC=$((_SL_ACC + 1)) done echo "SLICES_TOTAL: ${_SL_TOTAL:-0}" echo "SLICES_CLOSED_BY_WORK: $_SL_WORK" @@ -145,6 +152,8 @@ echo "SLICES_ACCEPTED: $_SL_ACC" ## Procedure +The current milestone's files named below (`{CURRENT_MILESTONE}-ROADMAP.md`, `-CONTEXT.md`, slice and task files) are read and edited in `{ARTIFACT_DIR}`: `.ytstack/` itself, or `milestones/M###/` when the milestone lives there. + **Step 2 HARD-GATE.** If `SLICE_COMPLETE=no`: abort with "slice still has open tasks. Close them via `summarize-task` before reassessing." **Step 3.** Collect recent summaries: read all `{MILESTONE}-{SLICE}-T##-SUMMARY.md` files. For each, extract Outcome + Deviations. Present to user: diff --git a/skills/retro/SKILL.md b/skills/retro/SKILL.md index 81212b0c..599e47ea 100644 --- a/skills/retro/SKILL.md +++ b/skills/retro/SKILL.md @@ -3,7 +3,7 @@ name: retro description: "Milestone retrospective fed with the milestone's task summaries, deviations and follow-ups plus the git history of the milestone window, written to M###-RETRO.md. Use after a milestone's last slice closed and reassess-roadmap ran, or when the user says retro, retrospective, what did we learn, lessons from this milestone. Not mid-milestone (reassess-roadmap) and not for closing a task (summarize-task)." metadata: tier: task - version: 1.3.0 + version: 1.3.1 upstream: "gstack v1.99.3.0 (retro/, commit 1d3c63c53)" allowed-tools: - Bash @@ -122,10 +122,17 @@ _M=none; _SUMMARIES=0; _RETRO_FILE=none; _PRIOR=none; _FIRST=none; _CREATED=none if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _M=$(sed -n 's/^current_milestone: *//p' "$_YT_DIR/STATE.md" | head -1); _M=${_M:-none} if [ "$_M" != none ]; then - _SUMMARIES=$(ls "$_YT_DIR"/$_M-S[0-9][0-9]-T[0-9][0-9]-SUMMARY.md 2>/dev/null | grep -c .) - _RETRO_FILE="$_YT_DIR/$_M-RETRO.md" - _PRIOR=$(ls "$_YT_DIR"/M[0-9][0-9][0-9]-RETRO.md 2>/dev/null | grep -v "/$_M-RETRO.md" | sort | tail -1); _PRIOR=${_PRIOR:-none} - [ -f "$_YT_DIR/$_M-CONTEXT.md" ] && _CREATED=$(sed -n 's/^created: *//p' "$_YT_DIR/$_M-CONTEXT.md" | head -1 | cut -c1-10) + # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) + if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_M"); else _AD="$_YT_DIR"; fi + _SUMMARIES=$(ls "$_AD"/$_M-S[0-9][0-9]-T[0-9][0-9]-SUMMARY.md 2>/dev/null | grep -c .) + _RETRO_FILE="$_AD/$_M-RETRO.md" + if command -v yt_find_artifacts >/dev/null 2>&1; then + _PRIOR=$(yt_find_artifacts "$_YT_DIR" 'M[0-9][0-9][0-9]-RETRO.md' | grep -v "/$_M-RETRO.md" | awk -F/ '{print $NF "\t" $0}' | sort | tail -1 | cut -f2-) + else + _PRIOR=$(ls "$_YT_DIR"/M[0-9][0-9][0-9]-RETRO.md 2>/dev/null | grep -v "/$_M-RETRO.md" | sort | tail -1) + fi + _PRIOR=${_PRIOR:-none} + [ -f "$_AD/$_M-CONTEXT.md" ] && _CREATED=$(sed -n 's/^created: *//p' "$_AD/$_M-CONTEXT.md" | head -1 | cut -c1-10) _CREATED=${_CREATED:-none} if command -v yt_commit_ref_pattern >/dev/null 2>&1; then _PAT=$(yt_commit_ref_pattern "$_YT_DIR" "$_M" 'S[0-9][0-9]' 'T[0-9][0-9]') @@ -133,13 +140,14 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _PAT="^$_M-S[0-9][0-9]-T[0-9][0-9]:" fi _FIRST=$(git log --no-merges -E --grep "$_PAT" --date=format-local:%Y-%m-%d --format=%ad 2>/dev/null | tail -1); _FIRST=${_FIRST:-none} - _TASKS_DONE=$(cat "$_YT_DIR"/$_M-S[0-9][0-9]-PLAN.md 2>/dev/null | grep -cE '^- \[[xX]\] T[0-9][0-9]') - _TASKS_ALL=$(cat "$_YT_DIR"/$_M-S[0-9][0-9]-PLAN.md 2>/dev/null | grep -cE '^- \[[ xX]\] T[0-9][0-9]') + _TASKS_DONE=$(cat "$_AD"/$_M-S[0-9][0-9]-PLAN.md 2>/dev/null | grep -cE '^- \[[xX]\] T[0-9][0-9]') + _TASKS_ALL=$(cat "$_AD"/$_M-S[0-9][0-9]-PLAN.md 2>/dev/null | grep -cE '^- \[[ xX]\] T[0-9][0-9]') fi fi _BASE=$(git symbolic-ref --quiet refs/remotes/origin/HEAD 2>/dev/null | sed 's|^refs/remotes/origin/||') for _C in main master; do [ -n "$_BASE" ] && break; git rev-parse --verify --quiet "$_C" >/dev/null 2>&1 && _BASE=$_C; done echo "MILESTONE: $_M" +echo "ARTIFACT_DIR: ${_AD:-$_YT_DIR}" echo "SUMMARIES: $_SUMMARIES" echo "RETRO_FILE: $_RETRO_FILE" echo "RETRO_EXISTS: $([ -f "$_RETRO_FILE" ] && echo yes || echo no)" @@ -190,7 +198,7 @@ The preamble above ran when the skill loaded. Read its flags; refer to them by n ### 3. Read the material -Read, with the Read tool, in this order: `/-CONTEXT.md` (goal, exit criteria, decisions locked during discuss), `/-ROADMAP.md`, every `/-S##-PLAN.md`, every `/-S##-T##-SUMMARY.md` (Commits, Outcome, Deviations, Follow-ups, Verification and the `verification:` frontmatter key), and `PRIOR_RETRO` when it is not `none` (its `## Snapshot` block holds the metrics and recommendations to compare against). +Read, with the Read tool, in this order: `/-CONTEXT.md` (goal, exit criteria, decisions locked during discuss), `/-ROADMAP.md`, every `/-S##-PLAN.md`, every `/-S##-T##-SUMMARY.md` (Commits, Outcome, Deviations, Follow-ups, Verification and the `verification:` frontmatter key), and `PRIOR_RETRO` when it is not `none` (its `## Snapshot` block holds the metrics and recommendations to compare against). Do not read unrelated docs. `CHANGELOG.md` and `TODOS.md` are read in step 6, nothing else outside `.ytstack/`. diff --git a/skills/ship/SKILL.md b/skills/ship/SKILL.md index 211b19bb..ce873ebb 100644 --- a/skills/ship/SKILL.md +++ b/skills/ship/SKILL.md @@ -3,7 +3,7 @@ name: ship description: "Ships the current branch (merge the base, tests, coverage and plan audit, pre-landing review, version and CHANGELOG, docs sync, commit, push, pull request), gated on ytstack's slice state. Use when a slice or milestone is closed on paper and verified, or when the user says ship it, open the PR, land this, create a PR. Not before every task of the slice has a summary (summarize-task), not for merging into the base locally (finish-branch), and never for a merge without an explicit merge instruction." metadata: tier: task - version: 1.0.2 + version: 1.0.3 upstream: "gstack v1.99.3.0 (ship/, commit 1d3c63c53)" allowed-tools: - Bash @@ -133,10 +133,12 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _S=$(sed -n 's/^active_slice: *//p' "$_YT_DIR/STATE.md" | head -1); _S=${_S:-none} echo "CURRENT_MILESTONE: $_M" echo "ACTIVE_SLICE: $_S" - if [ -f "$_YT_DIR/$_M-$_S-PLAN.md" ]; then - _SLICE_PLAN="$_YT_DIR/$_M-$_S-PLAN.md" + # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) + _ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } + if [ -f "$(_ap "$_M-$_S-PLAN.md")" ]; then + _SLICE_PLAN=$(_ap "$_M-$_S-PLAN.md") for t in $(grep -oE '^- \[.\] T[0-9][0-9] --' "$_SLICE_PLAN" | grep -oE 'T[0-9][0-9]'); do - f="$_YT_DIR/$_M-$_S-$t-SUMMARY.md" + f=$(_ap "$_M-$_S-$t-SUMMARY.md") { [ ! -f "$f" ] || grep -q '^closed: draft' "$f"; } && _OPEN_TASKS="$_OPEN_TASKS $t" done fi diff --git a/skills/slice-milestone/SKILL.md b/skills/slice-milestone/SKILL.md index a7ace35d..53a08fe3 100644 --- a/skills/slice-milestone/SKILL.md +++ b/skills/slice-milestone/SKILL.md @@ -3,7 +3,7 @@ name: slice-milestone description: "Breaks the current milestone into slices of one to seven tasks and writes M###-S##-PLAN.md per slice. Use after plan-milestone (and plan-ceo-review when it ran), or when the user says slice the milestone, plan the slices, break it down. Not for task-level detail (plan-task)." metadata: tier: core - version: 0.3.0 + version: 0.3.1 triggers: - slice milestone - plan slices @@ -95,7 +95,9 @@ if [ -f "$_YT_DIR/STATE.md" ]; then _CURRENT_MILESTONE=$(sed -n 's/^current_milestone: *//p' "$_YT_DIR/STATE.md" | head -1) fi -_ROADMAP="$_YT_DIR/$_CURRENT_MILESTONE-ROADMAP.md" +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +if command -v yt_artifact_dir >/dev/null 2>&1; then _ARTIFACT_DIR=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _ARTIFACT_DIR="$_YT_DIR"; fi +_ROADMAP="$_ARTIFACT_DIR/$_CURRENT_MILESTONE-ROADMAP.md" _UNPLANNED_SLICES="" if [ -f "$_ROADMAP" ]; then _UNPLANNED_SLICES=$(grep -oE 'S[0-9][0-9] -- \(to be planned\)' "$_ROADMAP" | grep -oE 'S[0-9][0-9]' | tr '\n' ' ') @@ -109,6 +111,7 @@ fi echo "HAS_YTSTACK: $_HAS_YTSTACK" echo "CURRENT_MILESTONE: $_CURRENT_MILESTONE" echo "ROADMAP: $_ROADMAP" +echo "ARTIFACT_DIR: $_ARTIFACT_DIR" echo "UNPLANNED_SLICES: ${_UNPLANNED_SLICES:-none}" echo "YTSTACK_NON_INTERACTIVE: $_NON_INTERACTIVE" ``` @@ -165,7 +168,7 @@ Remember as `_SLICE_TASKS` (preserve lines). Loop back to 3b. -**3d -- Write `M###-S##-PLAN.md`.** Use Write tool: +**3d -- Write `M###-S##-PLAN.md`.** Use Write tool. Path: `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-{SLICE_ID}-PLAN.md`, beside the roadmap (`.ytstack/` itself, or `milestones/M###/` when the milestone lives there): ```markdown --- diff --git a/skills/spawn-milestone-team/SKILL.md b/skills/spawn-milestone-team/SKILL.md index 5a77105a..f7bb5699 100644 --- a/skills/spawn-milestone-team/SKILL.md +++ b/skills/spawn-milestone-team/SKILL.md @@ -3,7 +3,7 @@ name: spawn-milestone-team description: "Dispatches the current milestone's slices to parallel workers: by default one worktree-isolated implementer subagent per slice plus a fresh verifier per slice, orchestrated from the main session which never edits source; with PREFERENCES team on, a Claude Code Agent Team instead. Use after slice-milestone and plan-eng-review when the slices are independent, or when the user says spawn the team, run the slices in parallel, dispatch the milestone. Not for a single slice or sequential work (plan-task)." metadata: tier: task - version: 0.5.0 + version: 0.5.1 triggers: - spawn team - dispatch milestone @@ -73,9 +73,12 @@ _CURRENT_MILESTONE=none [ -f "$_YT_DIR/STATE.md" ] && _CURRENT_MILESTONE=$(sed -n 's/^current_milestone: *//p' "$_YT_DIR/STATE.md" | head -1) _SLICE_PLANS="" +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _AD="$_YT_DIR"; fi if [ "$_CURRENT_MILESTONE" != none ] && [ -d "$_YT_DIR" ]; then - _SLICE_PLANS=$(ls "$_YT_DIR"/$_CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md 2>/dev/null) + _SLICE_PLANS=$(ls "$_AD"/$_CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md 2>/dev/null) fi +echo "ARTIFACT_DIR: $_AD" _SLICE_COUNT=$(printf '%s' "$_SLICE_PLANS" | grep -c . 2>/dev/null); _SLICE_COUNT=${_SLICE_COUNT:-0} # Open slices (status not done) and file overlap between their task plans / Files sections. @@ -89,7 +92,7 @@ if [ -n "$_OPEN_SLICES" ]; then _TMPF=$(mktemp "${TMPDIR:-/tmp}/ytspawn.XXXXXX") for s in $_OPEN_SLICES; do # file-like tokens: backticked `path.ext`, "Create/Modify/Delete: path", or bare dir/file.ext in the slice + task plans - cat "$_YT_DIR"/$_CURRENT_MILESTONE-$s-PLAN.md "$_YT_DIR"/$_CURRENT_MILESTONE-$s-T[0-9][0-9]-PLAN.md 2>/dev/null \ + cat "$_AD"/$_CURRENT_MILESTONE-$s-PLAN.md "$_AD"/$_CURRENT_MILESTONE-$s-T[0-9][0-9]-PLAN.md 2>/dev/null \ | grep -oE '(`[^` ]+\.[A-Za-z0-9]+`|(Create|Modify|Delete): *[A-Za-z0-9_./-]+\.[A-Za-z0-9]+|[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)+\.[A-Za-z0-9]+)' \ | sed -E 's/^(Create|Modify|Delete): *//' | tr -d '`' | sort -u | sed "s/^/$s /" done > "$_TMPF" @@ -278,7 +281,7 @@ Agent( isolation: "worktree", name: "verify-{CURRENT_MILESTONE}-S##", description: "Verify slice S## on its branch", - prompt: "Branch ytstack/{CURRENT_MILESTONE}-S##. Run `git checkout ytstack/{CURRENT_MILESTONE}-S##` in your worktree, then for every .ytstack/{CURRENT_MILESTONE}-S##-T##-PLAN.md run its Verification command from a cold context, as often as its Runs line says, and compare with the T##-SUMMARY.md claims (no summary: with the worker's report below). Report pass / pass-with-caveats / fail per task with the raw output and the commit you ran on. Do not edit anything. Worker's report: " + prompt: "Branch ytstack/{CURRENT_MILESTONE}-S##. Run `git checkout ytstack/{CURRENT_MILESTONE}-S##` in your worktree, then for every {CURRENT_MILESTONE}-S##-T##-PLAN.md in the milestone's directory under .ytstack/ (the same place relative to the checkout as {ARTIFACT_DIR}) run its Verification command from a cold context, as often as its Runs line says, and compare with the T##-SUMMARY.md claims (no summary: with the worker's report below). Report pass / pass-with-caveats / fail per task with the raw output and the commit you ran on. Do not edit anything. Worker's report: " ) ``` diff --git a/skills/summarize-task/SKILL.md b/skills/summarize-task/SKILL.md index 0e839869..3bb54cab 100644 --- a/skills/summarize-task/SKILL.md +++ b/skills/summarize-task/SKILL.md @@ -3,7 +3,7 @@ name: summarize-task description: "Closes the active task: writes M###-S##-T##-SUMMARY.md with commits, outcome, deviations, follow-ups and the verification result, flips the slice-plan checkbox and advances STATE. Use when a task's verification passed, or when the user says task done, close the task, summarize. Not before verification passed and not for quick-lane changes (quick-task writes its own summary)." metadata: tier: core - version: 0.3.0 + version: 0.3.1 triggers: - summarize task - task done @@ -83,13 +83,12 @@ if [ -f "$_YT_DIR/STATE.md" ]; then _ACTIVE_TASK=$(sed -n 's/^active_task: *//p' "$_YT_DIR/STATE.md" | head -1) fi -_PLAN_FILE="$_YT_DIR/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-$_ACTIVE_TASK-PLAN.md" -# M018-S03: tolerate milestones/M###/ layouts on the read side -if [ ! -f "$_PLAN_FILE" ] && command -v yt_find_artifacts >/dev/null 2>&1; then - _ALT=$(yt_find_artifacts "$_YT_DIR" "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-$_ACTIVE_TASK-PLAN.md" | head -1) - [ -n "$_ALT" ] && _PLAN_FILE="$_ALT" -fi -_SLICE_PLAN="$_YT_DIR/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md" +# Artifacts of the milestone: flat, or the directory it already lives in (issue #70) +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } +if command -v yt_artifact_dir >/dev/null 2>&1; then _ARTIFACT_DIR=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _ARTIFACT_DIR="$_YT_DIR"; fi +_PLAN_FILE=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-$_ACTIVE_TASK-PLAN.md") +_SLICE_PLAN=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md") +_ROADMAP=$(_ap "$_CURRENT_MILESTONE-ROADMAP.md") # Gather this task's commits for a durable, committed `## Commits` section. # ytstack's commit convention prefixes task commits with `M###-S##-T##:` @@ -121,6 +120,8 @@ echo "ACTIVE_SLICE: $_ACTIVE_SLICE" echo "ACTIVE_TASK: $_ACTIVE_TASK" echo "PLAN_FILE: $_PLAN_FILE" echo "SLICE_PLAN: $_SLICE_PLAN" +echo "ROADMAP: $_ROADMAP" +echo "ARTIFACT_DIR: $_ARTIFACT_DIR" echo "IS_GIT: $_IS_GIT" echo "COMMIT_PATTERN: $_COMMIT_PATTERN" echo "TASK_COMMITS_SOURCE: $_TASK_COMMITS_SOURCE" @@ -264,6 +265,8 @@ A sentence in the summary does not satisfy the check, and neither does an edit t ### Step 9: Write `M###-S##-T##-SUMMARY.md` +Path: `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{ACTIVE_TASK}-SUMMARY.md` (beside the milestone's other files; a draft stub found elsewhere is replaced where it is). + ```markdown --- milestone: {CURRENT_MILESTONE} @@ -340,7 +343,7 @@ Regardless of teammate mode: **Progress block (M021):** if the `STATE.md` frontmatter has a `progress:` block, update it in the same edit. Add 1 to `done` when the closed task is an item the block counts. Tasks are the default unit; a project that counts something else says so in a comment line inside the block, and `done` / `total` then follow that ledger. If the closed task was added after `total` was set, raise `total` as well. Never write `done` above `total`. Then run `yt_state_lint "$_YT_DIR"`: a warning that starts with `progress:` means the edit is wrong; fix it before Step 12. As a swarm teammate skip the block with the other frontmatter writes and note the pending increment under Follow-ups in the summary. No block: do nothing and do not add one. `bin/ytstack-status` shows these numbers in the status line (`docs/statusline.md`). -If the slice is now fully complete (all tasks `[x]`): update status to recommend `/ytstack:reassess-roadmap`, flip the slice's `status:` to `done` in `{SLICE_PLAN}` frontmatter, and when every slice in `{CURRENT_MILESTONE}-ROADMAP.md` is checked flip the milestone's `status:` to `done` there and mirror the global `ROADMAP.md` row (M018 artifact states). +If the slice is now fully complete (all tasks `[x]`): update status to recommend `/ytstack:reassess-roadmap`, flip the slice's `status:` to `done` in `{SLICE_PLAN}` frontmatter, and when every slice in `{ROADMAP}` is checked flip the milestone's `status:` to `done` there and mirror the global `ROADMAP.md` row (M018 artifact states). ### Step 12: Offer git stage @@ -366,7 +369,7 @@ Report: > Task **{ACTIVE_TASK}** closed. > -> Summary at: `{YT_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{ACTIVE_TASK}-SUMMARY.md` +> Summary at: `{ARTIFACT_DIR}/{CURRENT_MILESTONE}-{ACTIVE_SLICE}-{ACTIVE_TASK}-SUMMARY.md` > Spec: {SPEC_RECORD} > Slice-plan checkbox flipped. > STATE.md: `active_task` cleared. diff --git a/skills/test-driven-development/SKILL.md b/skills/test-driven-development/SKILL.md index 91597c8e..ffdf93a5 100644 --- a/skills/test-driven-development/SKILL.md +++ b/skills/test-driven-development/SKILL.md @@ -2,7 +2,7 @@ name: test-driven-development metadata: tier: core - version: 0.1.1 + version: 0.1.2 description: "Test-first implementation of the current task through the vendored superpowers test-driven-development procedure, with the task plan's files and verification command injected. Use during task execution for any feature, bugfix or refactor, before writing implementation code. Not without a task plan (plan-task or quick-task first)." allowed-tools: - Bash @@ -39,7 +39,8 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _S=$(sed -n 's/^active_slice: *//p' "$_YT_DIR/STATE.md" | head -1) _T=$(sed -n 's/^active_task: *//p' "$_YT_DIR/STATE.md" | head -1) fi -_TASK_PLAN="$_YT_DIR/$_M-$_S-$_T-PLAN.md" +# The plan lives with its milestone: flat or milestones/M###/ (issue #70) +if command -v yt_artifact_path >/dev/null 2>&1; then _TASK_PLAN=$(yt_artifact_path "$_YT_DIR" "$_M-$_S-$_T-PLAN.md"); else _TASK_PLAN="$_YT_DIR/$_M-$_S-$_T-PLAN.md"; fi echo "HAS_YTSTACK: $([ -n "$_YT_DIR" ] && echo yes || echo no)" echo "ACTIVE_TASK: $_M-$_S-$_T" echo "TASK_PLAN: $_TASK_PLAN" diff --git a/skills/verification-before-completion/SKILL.md b/skills/verification-before-completion/SKILL.md index e90ffd0a..74b55efb 100644 --- a/skills/verification-before-completion/SKILL.md +++ b/skills/verification-before-completion/SKILL.md @@ -2,7 +2,7 @@ name: verification-before-completion metadata: tier: core - version: 0.3.0 + version: 0.3.1 description: "Evidence before any done claim, through the vendored superpowers verification-before-completion procedure with the current task's verification command injected. Use before a commit, before a PR, before summarize-task, before telling the user that something works. Not a substitute for test-first work during implementation (test-driven-development)." allowed-tools: - Bash @@ -37,7 +37,8 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _S=$(sed -n 's/^active_slice: *//p' "$_YT_DIR/STATE.md" | head -1) _T=$(sed -n 's/^active_task: *//p' "$_YT_DIR/STATE.md" | head -1) fi -_TASK_PLAN="$_YT_DIR/$_M-$_S-$_T-PLAN.md" +# The plan lives with its milestone: flat or milestones/M###/ (issue #70) +if command -v yt_artifact_path >/dev/null 2>&1; then _TASK_PLAN=$(yt_artifact_path "$_YT_DIR" "$_M-$_S-$_T-PLAN.md"); else _TASK_PLAN="$_YT_DIR/$_M-$_S-$_T-PLAN.md"; fi _FENCE=$(printf '\140\140\140') _VERIFICATION="" if [ -f "$_TASK_PLAN" ]; then diff --git a/tests/skill-preambles.test.sh b/tests/skill-preambles.test.sh index ee003745..6909f8d0 100644 --- a/tests/skill-preambles.test.sh +++ b/tests/skill-preambles.test.sh @@ -544,6 +544,54 @@ cp "$TMP/tp.spec.bak" "$WT/.ytstack/M999-S01-T01-PLAN.md" ( cd "$WT" && git rm -rq .ytstack/spec && git commit -qm "chore: remove fixture spec" ) >/dev/null 2>&1 rm -f "$WT/.ytstack/spec/core.md"; rmdir "$WT/.ytstack/spec" 2>/dev/null +# A milestone that lives in milestones/M041/ (issue #70): readers find its files +# there and writers are pointed at the same directory, not at the flat layout. +echo "# milestone in milestones/M041/" +MV="$TMP/moved"; MD="$MV/.ytstack/milestones/M041"; mkdir -p "$MD" +( cd "$MV" || exit 2 + git init -q && git config user.email t@t.t && git config user.name t + printf 'project: fixture\nlast_updated: %s\ncurrent_milestone: M041\nactive_slice: S01\nactive_task: T01\n\n# State\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ytstack/STATE.md + printf 'name: fixture\n' > .ytstack/PROJECT.md + printf -- '---\nmilestone: M040\nstatus: done\n---\n' > .ytstack/M040-ROADMAP.md + printf -- '---\nmilestone: M041\ncreated: 2026-11-01T00:00:00Z\n---\n# M041\n' > "$MD/M041-CONTEXT.md" + printf -- '---\nmilestone: M041\nstatus: in-progress\n---\n- [ ] S01 -- one\n- [ ] S02 -- (to be planned)\n' > "$MD/M041-ROADMAP.md" + printf -- '---\nmilestone: M041\nslice: S01\n---\n- [ ] T01 -- a\n- [ ] T02 -- b\n' > "$MD/M041-S01-PLAN.md" + printf -- '---\ntask: T01\n---\n## Files\n\n- Modify: a.ts\n\n## Verification\n\n```bash\ntrue\n```\n' > "$MD/M041-S01-T01-PLAN.md" + echo seed > f.txt; git add -A; git commit -qm "M041-S01-T01: seed" ) >/dev/null 2>&1 || { echo FATAL moved fixture; exit 2; } +pre plan-task "$MV" +has "plan-task: moved -> slice plan found there" "$OUT" "SLICE_PLAN: $MD/M041-S01-PLAN.md" +has "plan-task: moved -> next task is T02 (T01 planned there)" "$OUT" "NEXT_TASK: T02" +has "plan-task: moved -> new task plan goes there" "$OUT" "ARTIFACT_DIR: $MD" +pre summarize-task "$MV" +has "summarize-task: moved -> task plan found there" "$OUT" "PLAN_FILE: $MD/M041-S01-T01-PLAN.md" +has "summarize-task: moved -> slice plan found there" "$OUT" "SLICE_PLAN: $MD/M041-S01-PLAN.md" +has "summarize-task: moved -> summary goes there" "$OUT" "ARTIFACT_DIR: $MD" +pre slice-milestone "$MV" +has "slice-milestone: moved -> roadmap found there" "$OUT" "ROADMAP: $MD/M041-ROADMAP.md" +has "slice-milestone: moved -> S02 still to plan" "$OUT" "UNPLANNED_SLICES: S02" +has "slice-milestone: moved -> slice plans go there" "$OUT" "ARTIFACT_DIR: $MD" +pre plan-milestone "$MV" +has "plan-milestone: moved milestones count for the number" "$OUT" "NEXT_MILESTONE: M042" +has "plan-milestone: a new milestone starts flat" "$OUT" "ARTIFACT_DIR: $MV/.ytstack" +pre reassess-roadmap "$MV" +has "reassess-roadmap: moved -> artifact dir" "$OUT" "ARTIFACT_DIR: $MD" +has "reassess-roadmap: moved -> slices counted from the moved roadmap" "$OUT" "SLICES_TOTAL: 2" +for s in test-driven-development verification-before-completion code-review; do + pre "$s" "$MV"; has "$s: moved -> task plan found there" "$OUT" "TASK_PLAN: $MD/M041-S01-T01-PLAN.md" +done +pre finish-branch "$MV"; has "finish-branch: moved -> both tasks open" "$OUT" "OPEN_TASKS: T01 T02" +pre ship "$MV"; has "ship: moved -> slice plan found there" "$OUT" "SLICE_PLAN: $MD/M041-S01-PLAN.md" +pre retro "$MV"; has "retro: moved -> tasks counted" "$OUT" "PLAN_TASKS: 0/2 done" +has "retro: moved -> retro goes there" "$OUT" "RETRO_FILE: $MD/M041-RETRO.md" +pre plan-ceo-review "$MV"; has "plan-ceo-review: moved -> milestone mode" "$OUT" "MODE: milestone" +has "plan-ceo-review: moved -> review goes there" "$OUT" "REVIEW_FILE: $MD/M041-CEO-REVIEW.md" +pre plan-eng-review "$MV"; has "plan-eng-review: moved -> review goes there" "$OUT" "REVIEW_FILE: $MD/M041-ENG-REVIEW.md" +has "plan-eng-review: moved -> the roadmap is read" "$OUT" "MILESTONE_DOC: $MD/M041-ROADMAP.md" +pre grill "$MV"; has "grill: moved -> CONTEXT there" "$OUT" "DESIGN_TARGET: $MD/M041-CONTEXT.md" +pre handoff-session "$MV"; has "handoff-session: moved -> artifact dir" "$OUT" "ARTIFACT_DIR: $MD" +pre spawn-milestone-team "$MV"; has "spawn-milestone-team: moved -> slice plan counted" "$OUT" "SLICE_COUNT: 1" +[ ! -e "$MV/.ytstack/M041-S01-PLAN.md" ] && ok "moved: nothing written flat by the preambles" || bad "moved: nothing written flat by the preambles" + # Fallback path: CLAUDE_SKILL_DIR left unsubstituted (foreign host) -> still resolves project scope echo "# fallback without lib" P=$(extract summarize-task); sed "s|$ROOT/skills/summarize-task|/nonexistent-skill-dir|g" "$P" > "$TMP/pre-fallback.sh" From 05f9b18eb82a4eaf1fac3c46f961abb710c9b62a Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 14:31:37 +0100 Subject: [PATCH 3/7] docs: new artifacts follow the directory a milestone lives in (#70) Spec areas artifacts and hooks-and-state, a DECISIONS entry and the Unreleased CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 --- .ytstack/DECISIONS.md | 21 +++++++++++++++++++++ .ytstack/spec/artifacts.md | 8 ++++---- .ytstack/spec/hooks-and-state.md | 2 +- CHANGELOG.md | 16 ++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/.ytstack/DECISIONS.md b/.ytstack/DECISIONS.md index 80459004..9250e902 100644 --- a/.ytstack/DECISIONS.md +++ b/.ytstack/DECISIONS.md @@ -1218,3 +1218,24 @@ Plus: ops-layer split during the same session (yopstack created as own public re **Chose:** A roadmap status `backlog` (frontmatter and the global ROADMAP column): planned, kept, not picked by `ytstack-frontier` while no milestone is current. Making it current sets `status: planned` and `current_milestone` again. **Supersedes:** None. Extends the roadmap state values in `docs/ux/skill-structure.md`. + +## 2026-11-15: New artifacts follow the directory a milestone already lives in (issue #70) + +**Context:** Reading tolerated `milestones/`, `milestones/*/`, `backlog/` and `backlog/*/` since M018-S03, but every skill and hook wrote flat into `.ytstack/`. A consumer that moved 299 files of older milestones into `.ytstack/milestones/M###/` got the next plan or summary of such a milestone back at the top level, beside the moved ones. + +**Options considered:** +- A) Keep writing flat and let `reconcile` move stragglers. Leaves the split after every task and needs a cleanup run per milestone. +- B) Move a milestone's files into `milestones/M###/` as soon as ytstack writes one. Moves user-owned files, which only `reconcile` may do, and changes this repository's own layout. +- C) Write where the milestone already lives: the directory that holds its roadmap, else any of its files, else flat. + +**Chose:** C. + +**Reason:** The person decided the layout by moving the files; ytstack follows it without moving anything. A milestone that lives flat, and every new milestone, stays flat, so nothing changes for projects that never moved files. + +**How to apply:** +- One lookup in `hooks/lib/git-ctx.sh`: `yt_artifact_dir ` for the directory, `yt_artifact_path ` for one file (where it exists, else in that directory). No skill or hook builds a milestone path as `$YT_DIR/M###-...` any more. +- Skills that write or read a milestone's files print `ARTIFACT_DIR` and fall back to `YT_DIR` when the library is not reachable. +- A file of the milestone that already exists elsewhere (a summary that landed flat before this fix) is read and replaced where it is, not duplicated. +- `bin/ytstack-risk` counts `M###-*` files in those directories as process records, like the flat ones. + +**Supersedes:** None. Narrows "Writing stays flat" of M018-S03 (`yt_find_artifacts`). diff --git a/.ytstack/spec/artifacts.md b/.ytstack/spec/artifacts.md index 1fca8aa1..209b5db0 100644 --- a/.ytstack/spec/artifacts.md +++ b/.ytstack/spec/artifacts.md @@ -36,7 +36,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory - `yt_resolve_yt_dir` in `hooks/lib/git-ctx.sh` picks the directory: `/.ytstack` if it exists (project scope, tracked in git), otherwise `~/.ytstack/projects/` (user scope), otherwise none. The repo key is a hash of the git common dir, so all worktrees of a repository share one user-scope directory. - `init-project` asks for project, user or both and records the answer as `scope:` in the `PROJECT.md` frontmatter. `both` writes identical files to both directories; the resolver then reads the project one. `adopt-brownfield` always uses project scope. - In project scope a linked worktree has its own copy of `.ytstack/` at its branch's state. -- Skills write a flat layout: every file directly in the directory, except `quick/`, `codebase/`, `backlog/` and `archive/`. Readers that go through `yt_find_artifacts` also find files under `milestones/`, `decisions/`, `backlog/` and `quick/`. +- Skills write a flat layout by default: every file directly in the directory, except `quick/`, `codebase/`, `backlog/` and `archive/`. Readers that go through `yt_find_artifacts` also find files under `milestones/`, `decisions/`, `backlog/` and `quick/`. A milestone whose files already live in a subdirectory keeps getting its new files there (issue #70). `yt_artifact_dir ` names the directory: the one that holds `-ROADMAP.md`, else the one that holds any `-*` file, searched flat first, then in `milestones/`, `milestones/*/`, `backlog/`, `backlog/*/`; else the flat directory. The prefix is the id up to its first `-` (`M005` for `M005-S02-T01`, `OPS` for a backlog prefix). `yt_artifact_path ` gives one file: where it exists, else in that directory. The skills that write or read a milestone's files print it as `ARTIFACT_DIR` (with `$_YT_DIR` as the fallback when the library is not reachable); `hooks/post-tool-use-bash` and `hooks/task-completed` write their summaries there. Nothing is moved, and a milestone that lives flat stays flat; `plan-milestone` counts moved milestones when it picks the next number. ### Files and writers @@ -165,9 +165,9 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - Templates: `skills/init-project/SKILL.md` and `skills/adopt-brownfield/SKILL.md` (the core files, `codebase/`, `backlog/`), `skills/plan-milestone/SKILL.md`, `skills/slice-milestone/SKILL.md`, `skills/plan-task/SKILL.md`, `skills/summarize-task/SKILL.md`, `skills/quick-task/SKILL.md`, `skills/handoff-session/SKILL.md`. - Cleanup: `skills/reconcile/SKILL.md`. States `dropped` and `shipped-informally`: `skills/reassess-roadmap/SKILL.md`. - Technical spec: scaffolds in `skills/init-project/SKILL.md` (Step 7) and `skills/adopt-brownfield/SKILL.md` (Steps 2 and 7); "Spec impact" in `skills/plan-task/SKILL.md` (Step 7); the closure check in `skills/summarize-task/SKILL.md` (preamble and Step 8); the tool `bin/ytstack-spec`; this repository's own spec under `.ytstack/spec/`. -- `hooks/lib/git-ctx.sh`: `yt_resolve_yt_dir`, `yt_state_lint`, `yt_progress_parse`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_state_base`, `yt_state_dir`, `yt_ensure_gitignore`. +- `hooks/lib/git-ctx.sh`: `yt_resolve_yt_dir`, `yt_state_lint`, `yt_progress_parse`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_artifact_dir`, `yt_artifact_path`, `yt_state_base`, `yt_state_dir`, `yt_ensure_gitignore`. - Hooks that touch artifacts: `hooks/post-tool-use-bash`, `hooks/task-completed`. Out-of-tree writers: `hooks/pre-compact`, `hooks/session-end`. -- Tests: `tests/git-ctx.test.sh` (scope resolution, state dirs, commit discovery, lint, `progress`, gitignore block), `tests/skill-preambles.test.sh` (`reconcile` classes, the external plan offer of `reconcile` and `adopt-brownfield`, `Q###` numbering, tracker, handoff lookup), `tests/post-tool-use-bash.test.sh` (stub once, ref match), `tests/pre-compact.test.sh` (`HANDOFF.md` untouched), `tests/ytstack-status.test.sh` (`progress` block). +- Tests: `tests/git-ctx.test.sh` (scope resolution, state dirs, commit discovery, lint, `progress`, gitignore block, the artifact directory), `tests/skill-preambles.test.sh` (a milestone in `milestones/M###/`, `reconcile` classes, the external plan offer of `reconcile` and `adopt-brownfield`, `Q###` numbering, tracker, handoff lookup), `tests/post-tool-use-bash.test.sh` (stub once, ref match), `tests/pre-compact.test.sh` (`HANDOFF.md` untouched), `tests/ytstack-status.test.sh` (`progress` block). ## How to verify @@ -191,7 +191,7 @@ Automatic handoffs and the session journal are not artifacts. `hooks/pre-compact - DECISIONS.md -- "2026-11-13: `STATE.md` is a pointer with a size bound; history leaves it through `reconcile`, a closed milestone is folded into the spec (M022-S03)"; "2026-11-15: A plan outside `.ytstack/` is detected by a script and mapped by the agent, after one question (M031-S05, issue #54)" (the external plan class) - DECISIONS.md -- "2026-11-13: Coordinator mode keeps lanes, questions and standing instructions in files and reads host facts fresh (M024, issue #34)" (the lanes table is not part of `STATE.md`, which narrows the proposal in issue #34) - DECISIONS.md -- "2026-11-14: Standing instructions are one file per entry in `.ytstack/standing/`; `STANDING.md` stays valid (issue #57)" -- DECISIONS.md -- "2026-04-23: `.ytstack/` location is user-chosen (project vs user vs both)" +- DECISIONS.md -- "2026-04-23: `.ytstack/` location is user-chosen (project vs user vs both)"; "2026-11-15: New artifacts follow the directory a milestone already lives in (issue #70)" - DECISIONS.md -- "2026-05-31: active_slice is plan-task-owned and team-member-guarded (M012 / issue #21-RC1)" - DECISIONS.md -- "2026-05-31: post-tool-use-bash is stub-once; summarize-task owns commit-to-task linking (M015 / issue #22)" - DECISIONS.md -- "2026-11-07: Hooks never write relative to CLAUDE_PROJECT_DIR; volatile state lives out-of-tree, per session and per worktree" (extends the stub-once entry to all hooks; ends hook writes to `HANDOFF.md` and the in-tree journal; user scope is keyed by the repo key, which narrows the slug path in the 2026-04-23 entry) diff --git a/.ytstack/spec/hooks-and-state.md b/.ytstack/spec/hooks-and-state.md index 603d796b..e5ab930e 100644 --- a/.ytstack/spec/hooks-and-state.md +++ b/.ytstack/spec/hooks-and-state.md @@ -35,7 +35,7 @@ The lifecycle hooks under `hooks/` and the shared library `hooks/lib/git-ctx.sh` - `yt_epoch` turns an ISO time into seconds with BSD `date -j`, GNU `date -d`, or, for BusyBox, `date -d` on the form `YYYY-MM-DD HH:MM:SS`. - `yt_brownfield_signals` counts up to six signs of an existing codebase and names which file would feed which artifact. The comment above the function lists the counted signals and the hint-only ones. - `yt_commit_ref_pattern` renders a task's commit pattern from `commit_ref_pattern` in `PREFERENCES.md`, or from the default. `yt_task_commits` lists commits whose subject matches it. When none match, it falls back to the commits on the current branch after the merge-base with the default branch, and reports which source it used. -- `yt_find_artifacts` lists artifacts newest first from the flat layout and from the alternative layouts named in its comment. Reading tolerates those layouts. Writing stays flat. +- `yt_find_artifacts` lists artifacts newest first from the flat layout and from the alternative layouts named in its comment. Reading tolerates those layouts. `yt_artifact_dir` and `yt_artifact_path` say where a milestone's files live and where its new ones go: the directory that already holds its roadmap or files, else flat ([artifacts.md](artifacts.md), "Location and scope"). `post-tool-use-bash`, `task-completed`, `stop`, `pre-tool-use-edit`, `session-start`, `task-created` and `teammate-idle` find the milestone's files through them. - `yt_factory_notices` returns one line per factory tool that is off although the project would use it, from local files only: risk routing (`spec/` without `REVIEW.md` or without an area whose frontmatter allows `auto_merge: low|normal`, quotes allowed, read with `yt_fm`, the reader `bin/ytstack-risk` uses; while `merge_by` is `risk`), the PR watch on a GitHub `origin` (no line in `~/.ytstack/config` that turns the hook on, read as `hooks/pr-watch` does: any `pr_watch=on` line; or `on` with a heartbeat missing or 10 minutes old; `yt_pr_watch_heartbeat` reads `watch.sqlite3`, else the time of `worker.lock`), and `RUNTIME.md` without "Release" or "Signals" while deploy or signal evidence exists (`ytstack-runtime sections`). `merge_by: human|coordinator` and `pr_watch=off` are choices and stay silent. `yt_read_stdin` also sets `YT_SOURCE`. - `yt_standing` lists the standing instructions in force from `.ytstack/standing/` (name, `given`, `scope`, tab separated), newest first by the time in the name (missing seconds count as `00`), without the entries another entry names in `supersedes`. It prints nothing without the directory; `STANDING.md` is read by the skills themselves. diff --git a/CHANGELOG.md b/CHANGELOG.md index 43e54aa0..602d31f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- **New artifacts follow the directory their milestone lives in** (issue #70): + when a milestone's roadmap or files already sit in + `.ytstack/milestones/M###/` (or a `backlog//` directory), new plans, + summaries, reviews and retros of that milestone are written there instead of + flat into `.ytstack/`. The lib functions `yt_artifact_dir` and + `yt_artifact_path` decide; skills print `ARTIFACT_DIR`. Flat stays the + default and nothing is moved. Readers that built flat paths (plan-task, + summarize-task, slice-milestone, reassess-roadmap, retro, the review and + execution skills, finish-branch, ship, spawn-milestone-team, grill, + handoff-session, and the stop, pre-tool-use-edit, session-start, + task-created, teammate-idle hooks) now find those files there too. + `plan-milestone` counts moved milestones when it numbers the next one, and + `ytstack-risk` counts their files as process records. + ## [0.11.0] - 2026-11-15 ### Added From a96ca51609e1fa1634b9be10c268b27149e0f13b Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 15:02:24 +0100 Subject: [PATCH 4/7] fix: hooks count a milestone's flat stragglers; risk records one level deep (#70) teammate-idle and task-created read the milestone's slice plans in every layout (yt_find_artifacts, one per name), so a plan that landed flat before the milestone moved still counts. teammate-idle no longer sums "0\n0" for a plan without an open task. ytstack-risk takes a milestone file in milestones/ or backlog/ as a process record only at most one directory below them, and no longer a path under a directory that is named like a milestone file. Co-Authored-By: Claude Opus 5.5 --- bin/ytstack-risk | 21 ++++++++++++++++----- hooks/task-created | 8 ++++++-- hooks/teammate-idle | 11 ++++++++--- tests/hooks-worktree.test.sh | 18 ++++++++++++++++++ tests/ytstack-risk.test.sh | 4 ++++ 5 files changed, 52 insertions(+), 10 deletions(-) diff --git a/bin/ytstack-risk b/bin/ytstack-risk index 7ab20b21..7ea911fc 100755 --- a/bin/ytstack-risk +++ b/bin/ytstack-risk @@ -391,15 +391,26 @@ print_reasons() { # is_record : a process record of the work itself. Exempt from the # coverage rule and from the size count; every other rule applies to it. is_record() { + local name="${1##*/}" rest case "$1" in .ytstack/STATE.md|.ytstack/LANES.md|.ytstack/KNOWLEDGE.md|.ytstack/ROADMAP.md) return 0 ;; .ytstack/quick/*|.ytstack/questions/*|"$EVIDENCE"/*) return 0 ;; - .ytstack/M[0-9][0-9][0-9]-*-PLAN.md|.ytstack/M[0-9][0-9][0-9]-*-SUMMARY.md) return 0 ;; - .ytstack/M[0-9][0-9][0-9]-CONTEXT.md|.ytstack/M[0-9][0-9][0-9]-ROADMAP.md|.ytstack/M[0-9][0-9][0-9]-SUMMARY.md) return 0 ;; esac - # The same files in the directory a milestone lives in (issue #70): judged by name. - case "$1" in .ytstack/milestones/*/M[0-9][0-9][0-9]-*|.ytstack/milestones/M[0-9][0-9][0-9]-*|.ytstack/backlog/*/M[0-9][0-9][0-9]-*|.ytstack/backlog/M[0-9][0-9][0-9]-*) - is_record ".ytstack/${1##*/}"; return ;; esac + # A milestone's files, judged by name: directly in .ytstack/, or in the + # directory a milestone lives in (issue #70): milestones/ or backlog/ and at + # most one directory below them. `*` in a case pattern also matches `/`, so + # the depth is checked on the path itself. + case "$1" in + .ytstack/"$name") ;; + .ytstack/milestones/*|.ytstack/backlog/*) + rest="${1#.ytstack/*/}" + case "$rest" in */*/*) return 1 ;; esac ;; + *) return 1 ;; + esac + case "$name" in + M[0-9][0-9][0-9]-*-PLAN.md|M[0-9][0-9][0-9]-*-SUMMARY.md) return 0 ;; + M[0-9][0-9][0-9]-CONTEXT.md|M[0-9][0-9][0-9]-ROADMAP.md|M[0-9][0-9][0-9]-SUMMARY.md) return 0 ;; + esac return 1 } diff --git a/hooks/task-created b/hooks/task-created index 89fd702e..65da5128 100644 --- a/hooks/task-created +++ b/hooks/task-created @@ -43,9 +43,13 @@ fi # Build the corpus: all slice-plans for the current milestone CORPUS_FILES="" -for plan in "$(yt_artifact_dir "$YT_DIR" "$CURRENT_MILESTONE")"/$CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md; do +# Every layout, one file per name: plans that landed flat before the milestone +# moved to milestones/M###/ count too (#70). +while IFS= read -r plan; do [ -f "$plan" ] && CORPUS_FILES="$CORPUS_FILES $plan" -done +done </dev/null || echo 0) + # grep -c prints 0 itself and exits 1; `|| echo 0` would yield "0\n0". + count=$(grep -c '^- \[ \] T[0-9][0-9]' "$plan" 2>/dev/null); count=${count:-0} OPEN_TASK_COUNT=$((OPEN_TASK_COUNT + count)) -done +done </dev/null "$MV/.ytstack/milestones/M050/M050-S01- fire teammate-idle "$MV" "$MV" '' case "$(cat "$TMP/err.teammate-idle")" in *"1 task(s) still open in milestone M050"*) ok "d: teammate-idle counts the moved slice plan";; *) bad "d: teammate-idle counts the moved slice plan" "$(cat "$TMP/err.teammate-idle")";; esac +# ---- (e) split state: roadmap moved, a slice plan still flat (#70) ----------- +echo "# (e) split state" +printf -- '---\nslice: S02\n---\n- [ ] T01 -- three (src/flat.ts)\n- [ ] T02 -- four\n' > "$MV/.ytstack/M050-S02-PLAN.md" +fire teammate-idle "$MV" "$MV" '' +case "$(cat "$TMP/err.teammate-idle")" in *"3 task(s) still open in milestone M050"*) ok "e: teammate-idle counts the flat straggler too";; *) bad "e: teammate-idle counts the flat straggler too" "$(cat "$TMP/err.teammate-idle")";; esac +printf '{"session_id":"se","cwd":%s,"hook_event_name":"TaskCreated","tool_input":{"subject":"touch src/flat.ts"}}' "$(jstr "$MV")" \ + | ( cd "$MV" && env CLAUDE_PLUGIN_DATA="$PD" CLAUDE_PROJECT_DIR="$MV" bash "$H/task-created" >/dev/null 2>"$TMP/err.tc" ); EC=$? +eq "e: task-created finds the file in the flat slice plan (no drift)" 0 "$EC" + +# ---- (f) every task done: teammate-idle lets the teammate idle --------------- +echo "# (f) all done" +printf -- '---\nslice: S01\n---\n- [x] T01 -- one\n- [x] T02 -- two\n' > "$MV/.ytstack/milestones/M050/M050-S01-PLAN.md" +printf -- '---\nslice: S02\n---\n- [x] T01 -- three\n' > "$MV/.ytstack/M050-S02-PLAN.md" +printf '{"session_id":"sf","cwd":%s,"hook_event_name":"TeammateIdle"}' "$(jstr "$MV")" \ + | ( cd "$MV" && env CLAUDE_PLUGIN_DATA="$PD" CLAUDE_PROJECT_DIR="$MV" bash "$H/teammate-idle" >/dev/null 2>"$TMP/err.ti" ); EC=$? +eq "f: no open task -> exit 0" 0 "$EC" +eq "f: no open task -> no message" "" "$(cat "$TMP/err.ti")" + echo echo "$PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ] diff --git a/tests/ytstack-risk.test.sh b/tests/ytstack-risk.test.sh index f68a2ea2..81f2affc 100644 --- a/tests/ytstack-risk.test.sh +++ b/tests/ytstack-risk.test.sh @@ -231,6 +231,10 @@ change "$R" bigrecord 'echo b >> src/auth/login.sh; awk "BEGIN { for (i = 0; i < eq "process records do not count towards the size" "floor: low" "$(line floor)" change "$R" bigrecord-moved 'echo b >> src/auth/login.sh; mkdir -p .ytstack/milestones/M001 && awk "BEGIN { for (i = 0; i < 500; i++) print \"l\" }" > .ytstack/milestones/M001/M001-S01-T01-PLAN.md'; fl eq "a record in milestones/M###/ is a process record too (#70)" "floor: low" "$(line floor)" +change "$R" bigrecord-deep 'echo b >> src/auth/login.sh; mkdir -p .ytstack/milestones/a/b && awk "BEGIN { for (i = 0; i < 500; i++) print \"l\" }" > .ytstack/milestones/a/b/M001-S01-T01-PLAN.md'; fl +[ "$(line floor)" != "floor: low" ] && ok "two directories below milestones/ is not a process record" || bad "two directories below milestones/ is not a process record" "$OUT" +change "$R" bigrecord-flatdir 'echo b >> src/auth/login.sh; mkdir -p .ytstack/M001-x && awk "BEGIN { for (i = 0; i < 500; i++) print \"l\" }" > .ytstack/M001-x/y-PLAN.md'; fl +[ "$(line floor)" != "floor: low" ] && ok "a directory named like a milestone file is not a process record" || bad "a directory named like a milestone file is not a process record" "$OUT" change "$R" binary 'printf "\0\1\2\3" > src/auth/blob.bin'; fl eq "a binary file is one file and no lines" "floor: low" "$(line floor)" From 8630a035b7356617bf05c77a8d0b70aad917cd9d Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 15:02:24 +0100 Subject: [PATCH 5/7] fix: skills list a milestone's files in every layout, also backlog/ (#70) reassess-roadmap (slice complete, gates, review rounds, slice counts), retro (summaries, slice plans, CONTEXT) and spawn-milestone-team (slice plans, overlap) list the milestone's files through yt_find_artifacts, one per name, so files that landed flat before the milestone moved count. plan-eng-review finds slice plans under backlog/ and backlog/*/ too (Codex review). Shell helpers use ${1} and awk `$ 0`, which Kimi does not expand. Co-Authored-By: Claude Opus 5.5 --- skills/finish-branch/SKILL.md | 2 +- skills/plan-eng-review/SKILL.md | 11 +++++-- skills/plan-task/SKILL.md | 2 +- skills/reassess-roadmap/SKILL.md | 23 ++++++++++----- skills/retro/SKILL.md | 21 +++++++++---- skills/ship/SKILL.md | 2 +- skills/spawn-milestone-team/SKILL.md | 14 ++++++--- skills/summarize-task/SKILL.md | 2 +- tests/skill-preambles.test.sh | 44 ++++++++++++++++++++++++++++ 9 files changed, 97 insertions(+), 24 deletions(-) diff --git a/skills/finish-branch/SKILL.md b/skills/finish-branch/SKILL.md index fa7a6425..0af93d1a 100644 --- a/skills/finish-branch/SKILL.md +++ b/skills/finish-branch/SKILL.md @@ -41,7 +41,7 @@ fi # Slice summary state: every task in the slice plan needs a non-draft summary before a branch is "done". _OPEN_TASKS=""; _DRAFT_SUMMARIES=0 # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) -_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "${1}"; else printf '%s\n' "$_YT_DIR/${1}"; fi; } _SP=$(_ap "$_M-$_S-PLAN.md") if [ -n "$_YT_DIR" ] && [ -f "$_SP" ]; then for t in $(grep -oE '^- \[.\] T[0-9][0-9] --' "$_SP" | grep -oE 'T[0-9][0-9]'); do diff --git a/skills/plan-eng-review/SKILL.md b/skills/plan-eng-review/SKILL.md index ee14524d..bbd85e48 100644 --- a/skills/plan-eng-review/SKILL.md +++ b/skills/plan-eng-review/SKILL.md @@ -133,9 +133,14 @@ fi # Milestone mode target: the current milestone's slice plans (flat or milestones/ layout). _SLICE_PLANS="" if [ "$_M" != none ] && [ -n "$_YT_DIR" ]; then - for _f in "$_YT_DIR/$_M"-S[0-9][0-9]-PLAN.md "$_YT_DIR"/milestones/"$_M"-S[0-9][0-9]-PLAN.md "$_YT_DIR"/milestones/*/"$_M"-S[0-9][0-9]-PLAN.md; do - [ -f "$_f" ] && _SLICE_PLANS="$_SLICE_PLANS$_f " - done + # Every layout the lib reads (flat, milestones/, backlog/ and one level below), one per name. + if command -v yt_find_artifacts >/dev/null 2>&1; then + _SLICE_PLANS=$(yt_find_artifacts "$_YT_DIR" "$_M-S[0-9][0-9]-PLAN.md" | awk -F/ 'NF && !s[$NF]++' | sort | tr '\n' ' ') + else + for _f in "$_YT_DIR/$_M"-S[0-9][0-9]-PLAN.md "$_YT_DIR"/milestones/"$_M"-S[0-9][0-9]-PLAN.md "$_YT_DIR"/milestones/*/"$_M"-S[0-9][0-9]-PLAN.md; do + [ -f "$_f" ] && _SLICE_PLANS="$_SLICE_PLANS$_f " + done + fi fi # Concept mode target: the office-hours pitch. _PITCH="" diff --git a/skills/plan-task/SKILL.md b/skills/plan-task/SKILL.md index 5772c8d7..54f07816 100644 --- a/skills/plan-task/SKILL.md +++ b/skills/plan-task/SKILL.md @@ -88,7 +88,7 @@ if [ -f "$_YT_DIR/STATE.md" ]; then fi # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) -_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "${1}"; else printf '%s\n' "$_YT_DIR/${1}"; fi; } if command -v yt_artifact_dir >/dev/null 2>&1; then _ARTIFACT_DIR=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _ARTIFACT_DIR="$_YT_DIR"; fi # If no active slice in STATE.md, infer the first unfinished slice from ROADMAP diff --git a/skills/reassess-roadmap/SKILL.md b/skills/reassess-roadmap/SKILL.md index b00ca08e..9500eb2b 100644 --- a/skills/reassess-roadmap/SKILL.md +++ b/skills/reassess-roadmap/SKILL.md @@ -78,9 +78,13 @@ fi # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _AD="$_YT_DIR"; fi +# One file wherever it is; all files of a glob in every layout, one per name (a +# milestone moved after some of its files landed flat has files in both places). +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "${1}"; else printf '%s\n' "$_YT_DIR/${1}"; fi; } +_fa() { if command -v yt_find_artifacts >/dev/null 2>&1; then yt_find_artifacts "$_YT_DIR" "${1}"; else ls "$_YT_DIR"/${1} 2>/dev/null; fi | awk -F/ 'NF && !s[$NF]++'; } # Determine if the current slice is complete -_SLICE_PLAN="$_AD/$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md" +_SLICE_PLAN=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md") _SLICE_COMPLETE=no if [ -f "$_SLICE_PLAN" ]; then # Open TASK lines only: an open gate (`- [ ] G01 --`) does not keep a slice @@ -126,25 +130,30 @@ echo "SPEC_DRIFT_END" # and the two progress numbers (closed by work, accepted). _GATE_RE='^- \[ \] G[0-9]+ --' echo "OPEN_GATES_BEGIN" -grep -Hn -E "$_GATE_RE" "$_AD"/"$_CURRENT_MILESTONE"-*PLAN.md 2>/dev/null | sed "s|^$_YT_DIR/||" +_fa "$_CURRENT_MILESTONE-*PLAN.md" | sort | while IFS= read -r _p; do + grep -Hn -E "$_GATE_RE" "$_p" 2>/dev/null | sed "s|^$_YT_DIR/||" +done echo "OPEN_GATES_END" echo "REVIEW_ROUNDS_BEGIN" -for _p in "$_AD"/"$_CURRENT_MILESTONE-$_ACTIVE_SLICE"-T[0-9][0-9]-PLAN.md; do +_fa "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-T[0-9][0-9]-PLAN.md" | sort | while IFS= read -r _p; do [ -f "$_p" ] || continue _r=$(grep -c -E '^- Round [0-9]+:' "$_p" 2>/dev/null); _r=${_r:-0} [ "$_r" -ge 3 ] && echo "$(basename "$_p" -PLAN.md): $_r review rounds" done echo "REVIEW_ROUNDS_END" _SL_TOTAL=0; _SL_WORK=0; _SL_ACC=0 -[ -f "$_AD/$_CURRENT_MILESTONE-ROADMAP.md" ] && _SL_TOTAL=$(grep -c -E '^- \[.\] S[0-9][0-9] --' "$_AD/$_CURRENT_MILESTONE-ROADMAP.md" 2>/dev/null) -for _sp in "$_AD"/"$_CURRENT_MILESTONE"-S[0-9][0-9]-PLAN.md; do +_RM=$(_ap "$_CURRENT_MILESTONE-ROADMAP.md") +[ -f "$_RM" ] && _SL_TOTAL=$(grep -c -E '^- \[.\] S[0-9][0-9] --' "$_RM" 2>/dev/null) +while IFS= read -r _sp; do [ -f "$_sp" ] || continue grep -q '^- \[ \] T[0-9]' "$_sp" && continue grep -q '^- \[[xX]\] T[0-9]' "$_sp" || continue _SL_WORK=$((_SL_WORK + 1)) _s=$(basename "$_sp" -PLAN.md) - cat "$_sp" "$_AD"/"$_s"-T[0-9][0-9]-PLAN.md 2>/dev/null | grep -q -E "$_GATE_RE" || _SL_ACC=$((_SL_ACC + 1)) -done + { cat "$_sp"; _fa "$_s-T[0-9][0-9]-PLAN.md" | while IFS= read -r _tp; do cat "$_tp"; done; } 2>/dev/null | grep -E "$_GATE_RE" >/dev/null || _SL_ACC=$((_SL_ACC + 1)) +done <<_SPS_ +$(_fa "$_CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md") +_SPS_ echo "SLICES_TOTAL: ${_SL_TOTAL:-0}" echo "SLICES_CLOSED_BY_WORK: $_SL_WORK" echo "SLICES_ACCEPTED: $_SL_ACC" diff --git a/skills/retro/SKILL.md b/skills/retro/SKILL.md index 599e47ea..0ae3299d 100644 --- a/skills/retro/SKILL.md +++ b/skills/retro/SKILL.md @@ -124,15 +124,21 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then if [ "$_M" != none ]; then # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_M"); else _AD="$_YT_DIR"; fi - _SUMMARIES=$(ls "$_AD"/$_M-S[0-9][0-9]-T[0-9][0-9]-SUMMARY.md 2>/dev/null | grep -c .) + # Every file of the milestone in every layout, one per name: files that + # landed flat before the milestone moved count too. + _fa() { if command -v yt_find_artifacts >/dev/null 2>&1; then yt_find_artifacts "$_YT_DIR" "${1}"; else ls "$_YT_DIR"/${1} 2>/dev/null; fi | awk -F/ 'NF && !s[$NF]++' | sort; } + _SUMMARY_FILES=$(_fa "$_M-S[0-9][0-9]-T[0-9][0-9]-SUMMARY.md") + _SLICE_FILES=$(_fa "$_M-S[0-9][0-9]-PLAN.md") + _SUMMARIES=$(printf '%s' "$_SUMMARY_FILES" | grep -c .) _RETRO_FILE="$_AD/$_M-RETRO.md" if command -v yt_find_artifacts >/dev/null 2>&1; then - _PRIOR=$(yt_find_artifacts "$_YT_DIR" 'M[0-9][0-9][0-9]-RETRO.md' | grep -v "/$_M-RETRO.md" | awk -F/ '{print $NF "\t" $0}' | sort | tail -1 | cut -f2-) + _PRIOR=$(yt_find_artifacts "$_YT_DIR" 'M[0-9][0-9][0-9]-RETRO.md' | grep -v "/$_M-RETRO.md" | awk -F/ '{print $NF "\t" $ 0}' | sort | tail -1 | cut -f2-) else _PRIOR=$(ls "$_YT_DIR"/M[0-9][0-9][0-9]-RETRO.md 2>/dev/null | grep -v "/$_M-RETRO.md" | sort | tail -1) fi _PRIOR=${_PRIOR:-none} - [ -f "$_AD/$_M-CONTEXT.md" ] && _CREATED=$(sed -n 's/^created: *//p' "$_AD/$_M-CONTEXT.md" | head -1 | cut -c1-10) + _CTX=$(_fa "$_M-CONTEXT.md" | head -1) + [ -n "$_CTX" ] && _CREATED=$(sed -n 's/^created: *//p' "$_CTX" | head -1 | cut -c1-10) _CREATED=${_CREATED:-none} if command -v yt_commit_ref_pattern >/dev/null 2>&1; then _PAT=$(yt_commit_ref_pattern "$_YT_DIR" "$_M" 'S[0-9][0-9]' 'T[0-9][0-9]') @@ -140,14 +146,17 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then _PAT="^$_M-S[0-9][0-9]-T[0-9][0-9]:" fi _FIRST=$(git log --no-merges -E --grep "$_PAT" --date=format-local:%Y-%m-%d --format=%ad 2>/dev/null | tail -1); _FIRST=${_FIRST:-none} - _TASKS_DONE=$(cat "$_AD"/$_M-S[0-9][0-9]-PLAN.md 2>/dev/null | grep -cE '^- \[[xX]\] T[0-9][0-9]') - _TASKS_ALL=$(cat "$_AD"/$_M-S[0-9][0-9]-PLAN.md 2>/dev/null | grep -cE '^- \[[ xX]\] T[0-9][0-9]') + _TASKS_DONE=$(printf '%s\n' "$_SLICE_FILES" | while IFS= read -r _f; do [ -f "$_f" ] && cat "$_f"; done | grep -cE '^- \[[xX]\] T[0-9][0-9]') + _TASKS_ALL=$(printf '%s\n' "$_SLICE_FILES" | while IFS= read -r _f; do [ -f "$_f" ] && cat "$_f"; done | grep -cE '^- \[[ xX]\] T[0-9][0-9]') fi fi _BASE=$(git symbolic-ref --quiet refs/remotes/origin/HEAD 2>/dev/null | sed 's|^refs/remotes/origin/||') for _C in main master; do [ -n "$_BASE" ] && break; git rev-parse --verify --quiet "$_C" >/dev/null 2>&1 && _BASE=$_C; done echo "MILESTONE: $_M" echo "ARTIFACT_DIR: ${_AD:-$_YT_DIR}" +echo "MILESTONE_FILES_BEGIN" +printf '%s\n' "${_SLICE_FILES:-}" "${_SUMMARY_FILES:-}" | grep . +echo "MILESTONE_FILES_END" echo "SUMMARIES: $_SUMMARIES" echo "RETRO_FILE: $_RETRO_FILE" echo "RETRO_EXISTS: $([ -f "$_RETRO_FILE" ] && echo yes || echo no)" @@ -198,7 +207,7 @@ The preamble above ran when the skill loaded. Read its flags; refer to them by n ### 3. Read the material -Read, with the Read tool, in this order: `/-CONTEXT.md` (goal, exit criteria, decisions locked during discuss), `/-ROADMAP.md`, every `/-S##-PLAN.md`, every `/-S##-T##-SUMMARY.md` (Commits, Outcome, Deviations, Follow-ups, Verification and the `verification:` frontmatter key), and `PRIOR_RETRO` when it is not `none` (its `## Snapshot` block holds the metrics and recommendations to compare against). +Read, with the Read tool, in this order: `/-CONTEXT.md` (goal, exit criteria, decisions locked during discuss), `/-ROADMAP.md`, every slice plan and every task summary listed between `MILESTONE_FILES_BEGIN` and `MILESTONE_FILES_END` (they can sit in `ARTIFACT_DIR` and flat) (Commits, Outcome, Deviations, Follow-ups, Verification and the `verification:` frontmatter key), and `PRIOR_RETRO` when it is not `none` (its `## Snapshot` block holds the metrics and recommendations to compare against). Do not read unrelated docs. `CHANGELOG.md` and `TODOS.md` are read in step 6, nothing else outside `.ytstack/`. diff --git a/skills/ship/SKILL.md b/skills/ship/SKILL.md index ce873ebb..d5a34cf3 100644 --- a/skills/ship/SKILL.md +++ b/skills/ship/SKILL.md @@ -134,7 +134,7 @@ if [ -n "$_YT_DIR" ] && [ -f "$_YT_DIR/STATE.md" ]; then echo "CURRENT_MILESTONE: $_M" echo "ACTIVE_SLICE: $_S" # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) - _ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } + _ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "${1}"; else printf '%s\n' "$_YT_DIR/${1}"; fi; } if [ -f "$(_ap "$_M-$_S-PLAN.md")" ]; then _SLICE_PLAN=$(_ap "$_M-$_S-PLAN.md") for t in $(grep -oE '^- \[.\] T[0-9][0-9] --' "$_SLICE_PLAN" | grep -oE 'T[0-9][0-9]'); do diff --git a/skills/spawn-milestone-team/SKILL.md b/skills/spawn-milestone-team/SKILL.md index f7bb5699..287e3cac 100644 --- a/skills/spawn-milestone-team/SKILL.md +++ b/skills/spawn-milestone-team/SKILL.md @@ -75,24 +75,30 @@ _CURRENT_MILESTONE=none _SLICE_PLANS="" # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) if command -v yt_artifact_dir >/dev/null 2>&1; then _AD=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _AD="$_YT_DIR"; fi +# Every file of a glob in every layout, one per name (files that landed flat +# before the milestone moved count too). +_fa() { if command -v yt_find_artifacts >/dev/null 2>&1; then yt_find_artifacts "$_YT_DIR" "${1}"; else ls "$_YT_DIR"/${1} 2>/dev/null; fi | awk -F/ 'NF && !s[$NF]++' | sort; } if [ "$_CURRENT_MILESTONE" != none ] && [ -d "$_YT_DIR" ]; then - _SLICE_PLANS=$(ls "$_AD"/$_CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md 2>/dev/null) + _SLICE_PLANS=$(_fa "$_CURRENT_MILESTONE-S[0-9][0-9]-PLAN.md") fi echo "ARTIFACT_DIR: $_AD" _SLICE_COUNT=$(printf '%s' "$_SLICE_PLANS" | grep -c . 2>/dev/null); _SLICE_COUNT=${_SLICE_COUNT:-0} # Open slices (status not done) and file overlap between their task plans / Files sections. _OPEN_SLICES=""; _OVERLAP="" -for p in $_SLICE_PLANS; do +while IFS= read -r p; do + [ -f "$p" ] || continue s=$(printf '%s' "$p" | sed -E 's/.*-(S[0-9][0-9])-PLAN\.md$/\1/') [ "$(sed -n 's/^status: *//p' "$p" | head -1)" = done ] && continue _OPEN_SLICES="$_OPEN_SLICES $s" -done +done <<_SPS_ +$_SLICE_PLANS +_SPS_ if [ -n "$_OPEN_SLICES" ]; then _TMPF=$(mktemp "${TMPDIR:-/tmp}/ytspawn.XXXXXX") for s in $_OPEN_SLICES; do # file-like tokens: backticked `path.ext`, "Create/Modify/Delete: path", or bare dir/file.ext in the slice + task plans - cat "$_AD"/$_CURRENT_MILESTONE-$s-PLAN.md "$_AD"/$_CURRENT_MILESTONE-$s-T[0-9][0-9]-PLAN.md 2>/dev/null \ + _fa "$_CURRENT_MILESTONE-$s*PLAN.md" | while IFS= read -r p; do cat "$p"; done 2>/dev/null \ | grep -oE '(`[^` ]+\.[A-Za-z0-9]+`|(Create|Modify|Delete): *[A-Za-z0-9_./-]+\.[A-Za-z0-9]+|[A-Za-z0-9_.-]+(/[A-Za-z0-9_.-]+)+\.[A-Za-z0-9]+)' \ | sed -E 's/^(Create|Modify|Delete): *//' | tr -d '`' | sort -u | sed "s/^/$s /" done > "$_TMPF" diff --git a/skills/summarize-task/SKILL.md b/skills/summarize-task/SKILL.md index 3bb54cab..150a0eb9 100644 --- a/skills/summarize-task/SKILL.md +++ b/skills/summarize-task/SKILL.md @@ -84,7 +84,7 @@ if [ -f "$_YT_DIR/STATE.md" ]; then fi # Artifacts of the milestone: flat, or the directory it already lives in (issue #70) -_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "$1"; else printf '%s\n' "$_YT_DIR/$1"; fi; } +_ap() { if command -v yt_artifact_path >/dev/null 2>&1; then yt_artifact_path "$_YT_DIR" "${1}"; else printf '%s\n' "$_YT_DIR/${1}"; fi; } if command -v yt_artifact_dir >/dev/null 2>&1; then _ARTIFACT_DIR=$(yt_artifact_dir "$_YT_DIR" "$_CURRENT_MILESTONE"); else _ARTIFACT_DIR="$_YT_DIR"; fi _PLAN_FILE=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-$_ACTIVE_TASK-PLAN.md") _SLICE_PLAN=$(_ap "$_CURRENT_MILESTONE-$_ACTIVE_SLICE-PLAN.md") diff --git a/tests/skill-preambles.test.sh b/tests/skill-preambles.test.sh index 6909f8d0..4e2d8e27 100644 --- a/tests/skill-preambles.test.sh +++ b/tests/skill-preambles.test.sh @@ -592,6 +592,43 @@ pre handoff-session "$MV"; has "handoff-session: moved -> artifact dir" " pre spawn-milestone-team "$MV"; has "spawn-milestone-team: moved -> slice plan counted" "$OUT" "SLICE_COUNT: 1" [ ! -e "$MV/.ytstack/M041-S01-PLAN.md" ] && ok "moved: nothing written flat by the preambles" || bad "moved: nothing written flat by the preambles" +# Split state (the consumer's in #70): the roadmap moved, some files of the same +# milestone still flat. Readers that count or list must see both places. +echo "# split: roadmap in milestones/M041/, stragglers flat" +SP="$TMP/split"; SD="$SP/.ytstack/milestones/M041"; mkdir -p "$SD" +( cd "$SP" || exit 2 + git init -q && git config user.email t@t.t && git config user.name t + printf 'project: fixture\nlast_updated: %s\ncurrent_milestone: M041\nactive_slice: S02\nactive_task: none\n\n# State\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ytstack/STATE.md + printf 'name: fixture\n' > .ytstack/PROJECT.md + printf -- '---\nmilestone: M041\nstatus: in-progress\n---\n- [ ] S01 -- one\n- [ ] S02 -- two\n' > "$SD/M041-ROADMAP.md" + printf -- '---\nslice: S01\n---\n- [x] T01 -- a\n- [ ] T02 -- b\n' > "$SD/M041-S01-PLAN.md" + printf -- '---\nclosed: 2026-11-01T00:00:00Z\n---\n' > "$SD/M041-S01-T01-SUMMARY.md" + printf -- '---\nslice: S02\n---\n- [x] T01 -- c\n' > .ytstack/M041-S02-PLAN.md + printf -- '---\nclosed: 2026-11-02T00:00:00Z\n---\n' > .ytstack/M041-S01-T02-SUMMARY.md + echo seed > f.txt; git add -A; git commit -qm "M041-S01-T01: seed" ) >/dev/null 2>&1 || { echo FATAL split fixture; exit 2; } +pre reassess-roadmap "$SP" +has "split: reassess-roadmap finds the flat slice plan complete" "$OUT" "SLICE_COMPLETE: yes" +has "split: reassess-roadmap counts the flat slice as closed by work" "$OUT" "SLICES_CLOSED_BY_WORK: 1" +pre retro "$SP" +has "split: retro counts both summaries" "$OUT" "SUMMARIES: 2" +has "split: retro counts the tasks of both slice plans" "$OUT" "PLAN_TASKS: 2/3 done" +has "split: retro lists the flat summary" "$OUT" "$SP/.ytstack/M041-S01-T02-SUMMARY.md" +pre spawn-milestone-team "$SP" +has "split: spawn-milestone-team counts both slice plans" "$OUT" "SLICE_COUNT: 2" + +# A milestone that lives in backlog// (Codex review on PR #77). +echo "# backlog: milestone in backlog/OLD/" +BL="$TMP/backlog"; BD="$BL/.ytstack/backlog/OLD"; mkdir -p "$BD" +( cd "$BL" || exit 2 + git init -q && git config user.email t@t.t && git config user.name t + printf 'project: fixture\nlast_updated: %s\ncurrent_milestone: M030\nactive_slice: S01\nactive_task: none\n\n# State\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > .ytstack/STATE.md + printf -- '---\nmilestone: M030\n---\n- [ ] S01 -- one\n' > "$BD/M030-ROADMAP.md" + printf -- '---\nslice: S01\n---\n- [ ] T01 -- a\n' > "$BD/M030-S01-PLAN.md" + echo seed > f.txt; git add -A; git commit -qm seed ) >/dev/null 2>&1 || { echo FATAL backlog fixture; exit 2; } +pre plan-eng-review "$BL" +has "backlog: plan-eng-review finds the slice plan -> milestone mode" "$OUT" "MODE: milestone" +has "backlog: plan-eng-review review goes there" "$OUT" "REVIEW_FILE: $BD/M030-ENG-REVIEW.md" + # Fallback path: CLAUDE_SKILL_DIR left unsubstituted (foreign host) -> still resolves project scope echo "# fallback without lib" P=$(extract summarize-task); sed "s|$ROOT/skills/summarize-task|/nonexistent-skill-dir|g" "$P" > "$TMP/pre-fallback.sh" @@ -599,6 +636,13 @@ run_pre "$TMP/pre-fallback.sh" "$WT" [ "$EC" -eq 0 ] && ok "fallback: runs" || bad "fallback: runs" "exit $EC" has "fallback: HAS_YTSTACK yes" "$OUT" "HAS_YTSTACK: yes" has "fallback: IS_GIT yes in worktree" "$OUT" "IS_GIT: yes" +has "fallback: ARTIFACT_DIR is the flat directory" "$OUT" "ARTIFACT_DIR: $WT/.ytstack" +for s in plan-task reassess-roadmap slice-milestone; do + P=$(extract "$s"); sed "s|$ROOT/skills/$s|/nonexistent-skill-dir|g" "$P" > "$TMP/pre-fallback-$s.sh" + run_pre "$TMP/pre-fallback-$s.sh" "$WT" + [ "$EC" -eq 0 ] && ok "fallback: $s runs" || bad "fallback: $s runs" "exit $EC" + has "fallback: $s ARTIFACT_DIR is the flat directory" "$OUT" "ARTIFACT_DIR: $WT/.ytstack" +done echo "# tree hygiene" [ -z "$(git -C "$MAIN" status --porcelain)" ] && ok "main checkout clean after all preambles" || bad "main checkout clean" "$(git -C "$MAIN" status --porcelain | head -3 | tr '\n' ' ')" From db0748149294933eefb59e0077b9e7315296858f Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 15:02:24 +0100 Subject: [PATCH 6/7] docs: CHANGELOG for the #70 review fixes Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 602d31f3..8820d531 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 handoff-session, and the stop, pre-tool-use-edit, session-start, task-created, teammate-idle hooks) now find those files there too. `plan-milestone` counts moved milestones when it numbers the next one, and - `ytstack-risk` counts their files as process records. + `ytstack-risk` counts their files as process records (at most one directory + below `milestones/` or `backlog/`). Readers that count or list a milestone's + files (reassess-roadmap, retro, spawn-milestone-team, task-created, + teammate-idle) also see files of that milestone that landed flat before it + moved. +- `teammate-idle` no longer fails on a slice plan without an open task (`grep + -c ... || echo 0` produced `0` twice and broke the sum). ## [0.11.0] - 2026-11-15 From 03539cac9998413009d13ed247b3b9cc5f292bbc Mon Sep 17 00:00:00 2001 From: Alex Wegener Date: Sun, 15 Nov 2026 15:13:40 +0100 Subject: [PATCH 7/7] docs: spec areas verified against the #70 changes skills: the preambles' artifact directory, the every-layout listing, the ${1} rule for Kimi, ARTIFACT_DIR in the fallback, the new preamble tests. checks-and-evals: process records in milestones/ and backlog/ one level deep. hooks-and-state, artifacts: hooks and skills that list a milestone's files read every layout. dependencies: nothing false. All five set verified_at to db07481. Co-Authored-By: Claude Opus 5.5 --- .ytstack/spec/artifacts.md | 4 ++-- .ytstack/spec/checks-and-evals.md | 4 ++-- .ytstack/spec/dependencies.md | 2 +- .ytstack/spec/hooks-and-state.md | 4 ++-- .ytstack/spec/skills.md | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.ytstack/spec/artifacts.md b/.ytstack/spec/artifacts.md index 209b5db0..f3172e79 100644 --- a/.ytstack/spec/artifacts.md +++ b/.ytstack/spec/artifacts.md @@ -20,7 +20,7 @@ sources: - docs/ux/signal-format.md - docs/statusline.md - docs/ux/external-plans.md -verified_at: c5b405d +verified_at: db07481 --- # artifacts @@ -36,7 +36,7 @@ The `.ytstack/` artifact model: the Markdown files that hold a project's memory - `yt_resolve_yt_dir` in `hooks/lib/git-ctx.sh` picks the directory: `/.ytstack` if it exists (project scope, tracked in git), otherwise `~/.ytstack/projects/` (user scope), otherwise none. The repo key is a hash of the git common dir, so all worktrees of a repository share one user-scope directory. - `init-project` asks for project, user or both and records the answer as `scope:` in the `PROJECT.md` frontmatter. `both` writes identical files to both directories; the resolver then reads the project one. `adopt-brownfield` always uses project scope. - In project scope a linked worktree has its own copy of `.ytstack/` at its branch's state. -- Skills write a flat layout by default: every file directly in the directory, except `quick/`, `codebase/`, `backlog/` and `archive/`. Readers that go through `yt_find_artifacts` also find files under `milestones/`, `decisions/`, `backlog/` and `quick/`. A milestone whose files already live in a subdirectory keeps getting its new files there (issue #70). `yt_artifact_dir ` names the directory: the one that holds `-ROADMAP.md`, else the one that holds any `-*` file, searched flat first, then in `milestones/`, `milestones/*/`, `backlog/`, `backlog/*/`; else the flat directory. The prefix is the id up to its first `-` (`M005` for `M005-S02-T01`, `OPS` for a backlog prefix). `yt_artifact_path ` gives one file: where it exists, else in that directory. The skills that write or read a milestone's files print it as `ARTIFACT_DIR` (with `$_YT_DIR` as the fallback when the library is not reachable); `hooks/post-tool-use-bash` and `hooks/task-completed` write their summaries there. Nothing is moved, and a milestone that lives flat stays flat; `plan-milestone` counts moved milestones when it picks the next number. +- Skills write a flat layout by default: every file directly in the directory, except `quick/`, `codebase/`, `backlog/` and `archive/`. Readers that go through `yt_find_artifacts` also find files under `milestones/`, `decisions/`, `backlog/` and `quick/`. A milestone whose files already live in a subdirectory keeps getting its new files there (issue #70). `yt_artifact_dir ` names the directory: the one that holds `-ROADMAP.md`, else the one that holds any `-*` file, searched flat first, then in `milestones/`, `milestones/*/`, `backlog/`, `backlog/*/`; else the flat directory. The prefix is the id up to its first `-` (`M005` for `M005-S02-T01`, `OPS` for a backlog prefix). `yt_artifact_path ` gives one file: where it exists, else in that directory. The skills that write or read a milestone's files print it as `ARTIFACT_DIR` (with `$_YT_DIR` as the fallback when the library is not reachable); `hooks/post-tool-use-bash` and `hooks/task-completed` write their summaries there. Skills and hooks that count or list a milestone's files read every layout, one file per name, so files that landed flat before the milestone moved count too. Nothing is moved, and a milestone that lives flat stays flat; `plan-milestone` counts moved milestones when it picks the next number. ### Files and writers diff --git a/.ytstack/spec/checks-and-evals.md b/.ytstack/spec/checks-and-evals.md index 5eb5af9d..1984c2e5 100644 --- a/.ytstack/spec/checks-and-evals.md +++ b/.ytstack/spec/checks-and-evals.md @@ -30,7 +30,7 @@ sources: - docs/ux/signal-format.md - docs/ux/external-plans.md - docs/ux/upstream-feedback.md -verified_at: c5b405d +verified_at: db07481 --- # checks-and-evals @@ -61,7 +61,7 @@ Everything that tells a contributor whether a change is acceptable: the static c **`bin/ytstack-risk`: whether a change may merge without a person** (`docs/ux/review-policy-format.md`) -- `floor --base --head ` prints the lowest class of the tree difference (`low`, `normal` or `person`), one `reason:` per path and rule, the touched areas, their ceiling and the required lenses. It reads the policy at the base commit, never from the working tree; git matches the globs. +- `floor --base --head ` prints the lowest class of the tree difference (`low`, `normal` or `person`), one `reason:` per path and rule, the touched areas, their ceiling and the required lenses. It reads the policy at the base commit, never from the working tree; git matches the globs. Process records (exempt from coverage and size) are the files the source lists, a milestone's files also in `milestones/` or `backlog/` and at most one directory below them. - `route [--plan ] [--pr [--repo ]] --base --head --author ` exits 0 with `route: unattended` only when the floor is not `person`, the newest round line approves, states `risk` and `invariants: none`, names a reviewer other than the author and is valid for the head, the class is within the ceiling, and every required lens has a passing line with its evidence (for `evidence: visual` a `MANIFEST` whose hashes match). Every other case exits 10 with `route: person` and one reason per failed condition. `by: self` and a missing `--author` always route to a person. With `--pr` the round and lens lines come first from the bodies of the pull request's reviews (one `gh api` read; submitted, not dismissed, by an owner, member or collaborator; the reviewer of a used line must have `admin`, `maintain` or `write` permission, read once per reviewer, a failed read routes to a person), each taken for the `commit_id` the host tied its review to; the plan counts only when no review carries a line of that kind, and a `round:` line names the source. A line naming another commit than the host's, a review that requests changes (also one without a record line, when it is its reviewer's newest review) and a failed read route to a person. - `check` validates `REVIEW.md`, its "Own reviewers" too (slug names, a unique `marker`, a `lessons` file that exists); `reviewers` prints the own reviewers tab separated; `manifest ` writes hash and name of every image into the `MANIFEST` of an evidence directory. diff --git a/.ytstack/spec/dependencies.md b/.ytstack/spec/dependencies.md index 8445ab21..de9c0daf 100644 --- a/.ytstack/spec/dependencies.md +++ b/.ytstack/spec/dependencies.md @@ -7,7 +7,7 @@ paths: - NOTICE - hooks/lib/git-ctx.sh - bin/ytstack-gstack-diff -verified_at: 8ca816a +verified_at: db07481 --- # dependencies diff --git a/.ytstack/spec/hooks-and-state.md b/.ytstack/spec/hooks-and-state.md index e5ab930e..63694680 100644 --- a/.ytstack/spec/hooks-and-state.md +++ b/.ytstack/spec/hooks-and-state.md @@ -10,7 +10,7 @@ sources: - docs/statusline.md - docs/pr-watch.md - docs/kimi.md -verified_at: c5b405d +verified_at: db07481 --- # hooks-and-state @@ -35,7 +35,7 @@ The lifecycle hooks under `hooks/` and the shared library `hooks/lib/git-ctx.sh` - `yt_epoch` turns an ISO time into seconds with BSD `date -j`, GNU `date -d`, or, for BusyBox, `date -d` on the form `YYYY-MM-DD HH:MM:SS`. - `yt_brownfield_signals` counts up to six signs of an existing codebase and names which file would feed which artifact. The comment above the function lists the counted signals and the hint-only ones. - `yt_commit_ref_pattern` renders a task's commit pattern from `commit_ref_pattern` in `PREFERENCES.md`, or from the default. `yt_task_commits` lists commits whose subject matches it. When none match, it falls back to the commits on the current branch after the merge-base with the default branch, and reports which source it used. -- `yt_find_artifacts` lists artifacts newest first from the flat layout and from the alternative layouts named in its comment. Reading tolerates those layouts. `yt_artifact_dir` and `yt_artifact_path` say where a milestone's files live and where its new ones go: the directory that already holds its roadmap or files, else flat ([artifacts.md](artifacts.md), "Location and scope"). `post-tool-use-bash`, `task-completed`, `stop`, `pre-tool-use-edit`, `session-start`, `task-created` and `teammate-idle` find the milestone's files through them. +- `yt_find_artifacts` lists artifacts newest first from the flat layout and from the alternative layouts named in its comment. Reading tolerates those layouts. `yt_artifact_dir` and `yt_artifact_path` say where a milestone's files live and where its new ones go: the directory that already holds its roadmap or files, else flat ([artifacts.md](artifacts.md), "Location and scope"). `post-tool-use-bash`, `task-completed`, `stop`, `pre-tool-use-edit` and `session-start` find the milestone's files through them; `task-created` and `teammate-idle` list its slice plans in every layout through `yt_find_artifacts`, one per name, so a plan that landed flat before the milestone moved counts too. - `yt_factory_notices` returns one line per factory tool that is off although the project would use it, from local files only: risk routing (`spec/` without `REVIEW.md` or without an area whose frontmatter allows `auto_merge: low|normal`, quotes allowed, read with `yt_fm`, the reader `bin/ytstack-risk` uses; while `merge_by` is `risk`), the PR watch on a GitHub `origin` (no line in `~/.ytstack/config` that turns the hook on, read as `hooks/pr-watch` does: any `pr_watch=on` line; or `on` with a heartbeat missing or 10 minutes old; `yt_pr_watch_heartbeat` reads `watch.sqlite3`, else the time of `worker.lock`), and `RUNTIME.md` without "Release" or "Signals" while deploy or signal evidence exists (`ytstack-runtime sections`). `merge_by: human|coordinator` and `pr_watch=off` are choices and stay silent. `yt_read_stdin` also sets `YT_SOURCE`. - `yt_standing` lists the standing instructions in force from `.ytstack/standing/` (name, `given`, `scope`, tab separated), newest first by the time in the name (missing seconds count as `00`), without the entries another entry names in `supersedes`. It prints nothing without the directory; `STANDING.md` is read by the skills themselves. diff --git a/.ytstack/spec/skills.md b/.ytstack/spec/skills.md index db359330..dbe5c7a2 100644 --- a/.ytstack/spec/skills.md +++ b/.ytstack/spec/skills.md @@ -8,7 +8,7 @@ sources: - docs/ux/skill-structure.md - docs/ux/askuserquestion-format.md - docs/ux/agent-structure.md -verified_at: b448b13 +verified_at: db07481 --- # skills @@ -42,9 +42,9 @@ Every native procedure and every wrapper starts its first shell block with the r - `yt_git_ctx "$PWD"`: the checkout is where the shell runs. It yields the toplevel, whether this is a linked worktree, and a repo key (a hash of the git common dir, shared by all worktrees of a repository). - `yt_resolve_yt_dir`: `/.ytstack` if it exists (project scope), otherwise `~/.ytstack/projects/` (user scope), otherwise none. -Further lib functions the preambles call: `yt_prefs`, `yt_state_lint`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_brownfield_signals`, `yt_ensure_gitignore`, `yt_state_base`. +Further lib functions the preambles call: `yt_prefs`, `yt_state_lint`, `yt_commit_ref_pattern`, `yt_task_commits`, `yt_find_artifacts`, `yt_artifact_dir`, `yt_artifact_path`, `yt_brownfield_signals`, `yt_ensure_gitignore`, `yt_state_base`. A skill that writes or reads a milestone's files prints `ARTIFACT_DIR`, the directory the milestone already lives in (flat, or `milestones/M###/`, see [artifacts.md](artifacts.md)), and writes its new files there. A skill that counts or lists a milestone's files (`reassess-roadmap`, `retro`, `spawn-milestone-team`, `plan-eng-review`) reads every layout through `yt_find_artifacts`, one file per name. Shell parameters in skill text are written `${1}`, awk fields `$ 1`, because Kimi expands `$1` in loaded skill text. -When the host does not substitute `${CLAUDE_SKILL_DIR}`, the block's fallback branch resolves project scope only. Lib-only values then print as defaults or `unknown`, and user scope is not found. +When the host does not substitute `${CLAUDE_SKILL_DIR}`, the block's fallback branch resolves project scope only. Lib-only values then print as defaults or `unknown`, `ARTIFACT_DIR` is the flat directory, and user scope is not found. A preamble prints `KEY: value` lines. The procedure refers to them by name. Each preamble prints the flags its own procedure uses; `HAS_YTSTACK` is the only one all of them print. @@ -158,7 +158,7 @@ Formats: `docs/ux/coordinator-format.md`. The four skills below are for the sess - `hooks/session-start`: injection of `using-ytstack` and the `minimal-code` pointer. - `vendor/superpowers/skills/`: the inlined procedures. - `bin/ytstack-check`: `check_skill`, `check_agent`, `check_cross_refs`, `check_resolver_contract`, `check_inline_leaks`, `check_gstack_adapted`. -- Tests: `tests/skill-preambles.test.sh` (every preamble in a main checkout and a linked worktree, preference flags, fallback branch), `tests/ytstack-check.test.sh` (checker rules), `tests/git-ctx.test.sh` (resolver, `yt_prefs`), `tests/hooks-readonly.test.sh` (injection size, `minimal_code` pointer). +- Tests: `tests/skill-preambles.test.sh` (every preamble in a main checkout and a linked worktree, preference flags, fallback branch, a milestone in `milestones/M###/`, `backlog//` and split between there and flat), `tests/ytstack-check.test.sh` (checker rules), `tests/git-ctx.test.sh` (resolver, `yt_prefs`), `tests/hooks-readonly.test.sh` (injection size, `minimal_code` pointer). - `evals/`: one trigger and outcome case per lifecycle skill, see `evals/README.md`. ## How to verify