@jeiemgi/cckit 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +15 -4
- package/README.md +11 -3
- package/bin/cckit +86 -7
- package/cckit.config.json +1 -1
- package/kit.config.schema.json +43 -2
- package/package.json +1 -1
- package/scripts/autopilot-test.sh +68 -0
- package/scripts/autopilot.sh +16 -10
- package/scripts/check.sh +14 -1
- package/scripts/copilot-loop-test.sh +3 -0
- package/scripts/guard-raw-git-ops-test.sh +65 -0
- package/scripts/init.sh +68 -8
- package/scripts/lib/agent-profile-test.sh +151 -0
- package/scripts/lib/agent-profile.sh +195 -0
- package/scripts/lib/agent-resolve-test.sh +156 -0
- package/scripts/lib/agent-resolve.sh +177 -0
- package/scripts/lib/branch-owner-test.sh +99 -0
- package/scripts/lib/branch-owner.sh +194 -0
- package/scripts/lib/captain-test.sh +86 -0
- package/scripts/lib/captain.sh +142 -7
- package/scripts/lib/contribute-root-test.sh +40 -0
- package/scripts/lib/contribute-root.sh +22 -0
- package/scripts/lib/effort-ops-test.sh +42 -2
- package/scripts/lib/effort-ops.sh +157 -14
- package/scripts/lib/effort-parity-test.sh +5 -3
- package/scripts/lib/effort.sh +38 -14
- package/scripts/lib/hook-refresh-test.sh +65 -0
- package/scripts/lib/hook-refresh.sh +62 -0
- package/scripts/lib/kit-config.sh +6 -0
- package/scripts/lib/kit-gc-test.sh +178 -1
- package/scripts/lib/kit-gc.sh +233 -55
- package/scripts/lib/kit-task-ops-test.sh +15 -0
- package/scripts/lib/kit-task-ops.sh +65 -21
- package/scripts/lib/kto-task-pr-merge-test.sh +72 -0
- package/scripts/lib/kto-task-pr-test.sh +59 -0
- package/scripts/lib/orchestration-runtime-test.sh +142 -0
- package/scripts/lib/orchestration-runtime.sh +171 -0
- package/scripts/lib/review-stage-test.sh +241 -0
- package/scripts/lib/review-stage.sh +259 -0
- package/scripts/lib/stage-receipt-test.sh +252 -0
- package/scripts/lib/stage-receipt.sh +442 -0
- package/scripts/lib/test-env-test.sh +25 -0
- package/scripts/lib/test-env.sh +30 -0
- package/scripts/lib/worker-brief-test.sh +120 -0
- package/scripts/lib/worker-brief.sh +185 -0
- package/scripts/lib/worktree-ports-test.sh +146 -0
- package/scripts/lib/worktree-start.sh +137 -7
- package/scripts/lib/zsh-safety-test.sh +67 -0
- package/scripts/orchestrate.sh +124 -22
- package/scripts/portable-test.sh +22 -1
- package/scripts/review-lint-baseline.txt +28 -0
- package/scripts/review-lint-test.sh +271 -0
- package/scripts/review-lint.sh +259 -0
- package/scripts/review-rules.conf +55 -0
- package/scripts/setup-labels.sh +21 -1
- package/scripts/skill-frontmatter-baseline.txt +24 -0
- package/scripts/skill-frontmatter-lint-test.sh +156 -0
- package/scripts/skill-frontmatter-lint.sh +182 -0
- package/scripts/task-sync.sh +8 -0
- package/scripts/test.sh +10 -1
- package/skills/kit-autopilot/SKILL.md +13 -1
- package/skills/kit-cleanup/SKILL.md +5 -3
- package/skills/kit-contribute/SKILL.md +6 -5
- package/skills/kit-effort-close/SKILL.md +8 -3
- package/skills/kit-effort-pr/SKILL.md +16 -95
- package/skills/kit-gc/SKILL.md +15 -10
- package/skills/kit-security-sweep/SKILL.md +4 -6
- package/skills/kit-ship/SKILL.md +1 -1
- package/skills/kit-task-pr/SKILL.md +2 -0
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +180 -0
- package/templates/rules/branch-naming.md +6 -0
- package/templates/rules/effort-model.md +3 -0
- package/templates/rules/naming-and-ids.md +4 -1
- package/templates/settings/settings.json.tmpl +4 -2
|
@@ -214,7 +214,13 @@ effort_new() {
|
|
|
214
214
|
_eff_ensure_label "$ctx" bfd4f2 "effort session weight"
|
|
215
215
|
_eff_ensure_label "kind:task" d4c5f9 "kit issue kind"
|
|
216
216
|
_eff_ensure_label "priority:$priority" e99695 "kit priority"
|
|
217
|
-
|
|
217
|
+
# `effort` is what marks the parent AS an effort, and it is the label `effort_plan` queries
|
|
218
|
+
# (`gh issue list --label effort`, effort-plan.sh). It was read and never written: the label did
|
|
219
|
+
# not exist in this repo at all, so `cckit effort plan` answered "no open efforts found" for
|
|
220
|
+
# every effort ever created here. A label something reads and nothing writes is the same defect
|
|
221
|
+
# as one something writes and nothing reads — see rules/naming-and-ids.md § Labels.
|
|
222
|
+
_eff_ensure_label "effort" 5319e7 "an effort parent issue"
|
|
223
|
+
local labels="effort,$ctx,kind:task,priority:$priority"
|
|
218
224
|
if [ -n "$role" ]; then
|
|
219
225
|
_eff_ensure_label "role:$role" 0e8a16 "kit role lane"
|
|
220
226
|
labels="$labels,role:$role"
|
|
@@ -648,8 +654,25 @@ effort_start() {
|
|
|
648
654
|
|
|
649
655
|
# effort_pr [<slug|N>] — open the single PR effort/<N> → base. Defaults to the current effort branch.
|
|
650
656
|
effort_pr() {
|
|
657
|
+
# The ONE effort-PR implementation (#363). The kit-effort-pr skill calls this; before, the skill
|
|
658
|
+
# carried its own inline copy, so agents hand-copied the script and the copy drifted (a PR missing
|
|
659
|
+
# from the board, a mangled body). Args: [<slug|N>] [--summary S|--summary-file F]
|
|
660
|
+
# [--for-agents A|--for-agents-file F] [--message M] [--title T]. SUMMARY / FOR_AGENTS / COMMIT_MSG env are
|
|
661
|
+
# honoured as fallbacks.
|
|
651
662
|
_eff_need gh || return 1
|
|
652
|
-
local raw="${
|
|
663
|
+
local raw="" summary="${SUMMARY:-}" for_agents="${FOR_AGENTS:-}" msg="${COMMIT_MSG:-}" title_override=""
|
|
664
|
+
while [ $# -gt 0 ]; do
|
|
665
|
+
case "$1" in
|
|
666
|
+
--summary) summary="${2:-}"; shift 2 ;;
|
|
667
|
+
--summary-file) summary="$(cat "${2:-/dev/null}")"; shift 2 ;;
|
|
668
|
+
--for-agents) for_agents="${2:-}"; shift 2 ;;
|
|
669
|
+
--for-agents-file) for_agents="$(cat "${2:-/dev/null}")"; shift 2 ;;
|
|
670
|
+
--message|-m) msg="${2:-}"; shift 2 ;;
|
|
671
|
+
--title) title_override="${2:-}"; shift 2 ;;
|
|
672
|
+
*) [ -z "$raw" ] && raw="$1"; shift ;;
|
|
673
|
+
esac
|
|
674
|
+
done
|
|
675
|
+
local num repo base branch meta title labels milestone role role_disp name pr_title body url author
|
|
653
676
|
repo="$(_eff_repo)"; base="$(_eff_base)"
|
|
654
677
|
branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"
|
|
655
678
|
if [ -n "$raw" ]; then
|
|
@@ -660,16 +683,110 @@ effort_pr() {
|
|
|
660
683
|
[ -n "$num" ] || { echo "effort_pr: not on an effort/<N>-… branch and no <slug|N> given" >&2; return 1; }
|
|
661
684
|
case "$branch" in effort/"$num"-*) : ;; *) echo "effort_pr: current branch ($branch) is not effort/$num-…" >&2; return 1 ;; esac
|
|
662
685
|
|
|
663
|
-
|
|
664
|
-
|
|
686
|
+
# Parent metadata: the PR inherits its labels + milestone, and the role names the title.
|
|
687
|
+
meta="$(gh issue view "$num" --repo "$repo" --json title,labels,milestone 2>/dev/null)"
|
|
688
|
+
title="$(printf '%s' "$meta" | jq -r '.title // ""' 2>/dev/null)"
|
|
689
|
+
labels="$(printf '%s' "$meta" | jq -r '[.labels[]?.name] | join(",")' 2>/dev/null)"
|
|
690
|
+
milestone="$(printf '%s' "$meta" | jq -r '.milestone.title // ""' 2>/dev/null)"
|
|
691
|
+
role="$(printf '%s' "$labels" | tr ',' '\n' | sed -n 's/^role://p' | head -1)"
|
|
692
|
+
role_disp=""
|
|
693
|
+
if [ -n "$role" ] && command -v role_display >/dev/null 2>&1; then
|
|
694
|
+
role_disp="$(role_display "$role" 2>/dev/null || true)"
|
|
695
|
+
fi
|
|
665
696
|
name="$(printf '%s' "$title" | sed -E 's/^\[Effort\] [0-9]+ · ?//')"
|
|
666
|
-
|
|
667
|
-
#
|
|
668
|
-
|
|
697
|
+
|
|
698
|
+
# Commit pending changes. Role identity is a Co-authored-by TRAILER, never the git author (some
|
|
699
|
+
# deploy providers refuse commits whose author email matches no account). TRACKED changes only:
|
|
700
|
+
# `git add -A` here would sweep a copied .env.local into the PR. Untracked files are listed, not
|
|
701
|
+
# committed — an effort's new files land in its per-sub commits.
|
|
702
|
+
if [ -n "$(git ls-files --others --exclude-standard 2>/dev/null)" ]; then
|
|
703
|
+
echo "effort_pr: untracked files NOT committed (commit them in their sub's commit if they belong):" >&2
|
|
704
|
+
git ls-files --others --exclude-standard 2>/dev/null | sed 's/^/ /' >&2
|
|
705
|
+
fi
|
|
706
|
+
if [ -n "$(git status --porcelain --untracked-files=no 2>/dev/null)" ]; then
|
|
707
|
+
author=""
|
|
708
|
+
git add -u
|
|
709
|
+
if [ -n "$role" ] && command -v role_git_author >/dev/null 2>&1; then
|
|
710
|
+
author="$(role_git_author "$role" 2>/dev/null || true)"
|
|
711
|
+
fi
|
|
712
|
+
if [ -n "$author" ]; then
|
|
713
|
+
git commit -q -m "${msg:-$role: ${name:-effort $num}}" -m "Co-authored-by: ${author%%|*} <${author##*|}>" || return 1
|
|
714
|
+
else
|
|
715
|
+
git commit -q -m "${msg:-${role:-chore}: ${name:-effort $num}}" || return 1
|
|
716
|
+
fi
|
|
717
|
+
fi
|
|
718
|
+
git push -u origin "$branch" >/dev/null 2>&1 || echo "effort_pr: push of $branch failed — continuing (the PR may already be current)" >&2
|
|
719
|
+
|
|
720
|
+
# ONE shared composer (effort.sh) so every surface titles identically, then the mandatory-[#N]
|
|
721
|
+
# check before we ever call gh — refuse rather than open an id-less PR (#121).
|
|
722
|
+
# --title serves a repo whose PR titles follow another convention (Conventional Commits under a
|
|
723
|
+
# commitlint gate); it must still carry the [#N] id, checked below.
|
|
724
|
+
pr_title="${title_override:-$(effort_pr_title "$num" "${name:-effort}" "$role_disp")}"
|
|
669
725
|
effort_pr_title_check "$pr_title" "$num" || { echo "effort_pr: refusing to open a PR without the [#$num] effort id" >&2; return 1; }
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
726
|
+
body="$(_eff_pr_body "$num" "$summary" "$for_agents" "$role")"
|
|
727
|
+
|
|
728
|
+
# Four explicit forms, not ${x:+--flag "$x"}: that idiom word-splits under zsh, and this file is
|
|
729
|
+
# sourced from zsh too.
|
|
730
|
+
if [ -n "$labels" ] && [ -n "$milestone" ]; then
|
|
731
|
+
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" --title "$pr_title" --body "$body" \
|
|
732
|
+
--label "$labels" --milestone "$milestone" --assignee "@me")" || return 1
|
|
733
|
+
elif [ -n "$labels" ]; then
|
|
734
|
+
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" --title "$pr_title" --body "$body" \
|
|
735
|
+
--label "$labels" --assignee "@me")" || return 1
|
|
736
|
+
elif [ -n "$milestone" ]; then
|
|
737
|
+
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" --title "$pr_title" --body "$body" \
|
|
738
|
+
--milestone "$milestone" --assignee "@me")" || return 1
|
|
739
|
+
else
|
|
740
|
+
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" --title "$pr_title" --body "$body" \
|
|
741
|
+
--assignee "@me")" || return 1
|
|
742
|
+
fi
|
|
743
|
+
echo "✓ $url"
|
|
744
|
+
_eff_pr_board "$num" "$url" "$role"
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
# _eff_pr_body <num> <summary> <for-agents> [role] — the effort PR body: the orchestrator header,
|
|
748
|
+
# `Closes #N`, a human Summary, the agent-facing For agents block, and a Verification checklist.
|
|
749
|
+
# An empty section prints a visible placeholder, never nothing, so a reviewer sees what is missing.
|
|
750
|
+
_eff_pr_body() {
|
|
751
|
+
local num="$1" summary="$2" for_agents="$3" role="${4:-}" sig=""
|
|
752
|
+
if [ -n "$role" ] && command -v role_signature >/dev/null 2>&1; then
|
|
753
|
+
sig="$(role_signature "$role" 2>/dev/null || true)"
|
|
754
|
+
fi
|
|
755
|
+
printf '## For the orchestrator\n\nEffort #%s — one PR for the whole effort. Review: the summary below + the diff.\n\nCloses #%s\n\n' "$num" "$num"
|
|
756
|
+
printf '## Summary\n\n%s\n\n' "${summary:-_(no summary given — pass --summary)_}"
|
|
757
|
+
printf '## For agents\n\n%s\n\n' "${for_agents:-See #$num for the goal, scope, and entry points.}"
|
|
758
|
+
printf '## Verification\n\n- [ ] Each sub-issue change is present in the diff\n- [ ] No unrelated files in the diff\n- [ ] Labels + milestone match the parent issue\n- [ ] Local lint/typecheck pass\n'
|
|
759
|
+
[ -n "$sig" ] && printf '\n%s\n' "$sig"
|
|
760
|
+
return 0
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
# _eff_pr_board <num> <pr-url> [role] — add the PR to the board at In Review (+ Role) and move the
|
|
764
|
+
# parent to In Review. A no-op unless Projects v2 is on; a failed PR add is reported, never silent.
|
|
765
|
+
_eff_pr_board() {
|
|
766
|
+
local num="$1" url="$2" role="${3:-}" repo pr_num node item ropt parent
|
|
767
|
+
[ "${KIT_PROJECTS_V2:-}" = "true" ] || return 0
|
|
768
|
+
_eo_source_board
|
|
769
|
+
command -v project_add_item >/dev/null 2>&1 || return 0
|
|
770
|
+
repo="$(_eff_repo)"; pr_num="${url##*/}"
|
|
771
|
+
node="$(gh api "repos/$repo/pulls/$pr_num" --jq .node_id 2>/dev/null)"
|
|
772
|
+
item=""
|
|
773
|
+
[ -n "$node" ] && item="$(project_add_item "$node" 2>/dev/null || true)"
|
|
774
|
+
if [ -z "$item" ]; then
|
|
775
|
+
echo "⚠ PR #$pr_num was opened but NOT added to the board — add it by hand" >&2
|
|
776
|
+
else
|
|
777
|
+
if [ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_IN_REVIEW:-}" ]; then
|
|
778
|
+
project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW" >/dev/null 2>&1 || true
|
|
779
|
+
fi
|
|
780
|
+
if [ -n "$role" ] && [ -n "${ROLE_FIELD_ID:-}" ] && command -v role_option_id >/dev/null 2>&1; then
|
|
781
|
+
ropt="$(role_option_id "$role" 2>/dev/null || true)"
|
|
782
|
+
[ -n "$ropt" ] && { project_set_single_select "$item" "$ROLE_FIELD_ID" "$ropt" >/dev/null 2>&1 || true; }
|
|
783
|
+
fi
|
|
784
|
+
fi
|
|
785
|
+
parent="$(project_find_item_by_issue "$num" 2>/dev/null || true)"
|
|
786
|
+
if [ -n "$parent" ] && [ -n "${STATUS_FIELD_ID:-}" ] && [ -n "${STATUS_OPT_IN_REVIEW:-}" ]; then
|
|
787
|
+
project_set_single_select "$parent" "$STATUS_FIELD_ID" "$STATUS_OPT_IN_REVIEW" >/dev/null 2>&1 || true
|
|
788
|
+
fi
|
|
789
|
+
return 0
|
|
673
790
|
}
|
|
674
791
|
|
|
675
792
|
# _eo_source_metrics — lazily source effort-metrics.sh so effort_close can call the shipped
|
|
@@ -682,6 +799,16 @@ _eo_source_metrics() {
|
|
|
682
799
|
[ -f "$d/effort-metrics.sh" ] && . "$d/effort-metrics.sh"
|
|
683
800
|
}
|
|
684
801
|
|
|
802
|
+
# _eo_source_gc — lazily source kit-gc.sh so effort_close can collect the effort's `sub/<N>…`
|
|
803
|
+
# worktrees + branches through the LANDED prune path (#388) — the ONE classifier, never a second
|
|
804
|
+
# `git branch -D` loop here. No-op if already loaded; a missing file degrades to "no sub GC".
|
|
805
|
+
_eo_source_gc() {
|
|
806
|
+
command -v kit_gc_prune >/dev/null 2>&1 && return 0
|
|
807
|
+
local d; d="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
808
|
+
# shellcheck source=/dev/null
|
|
809
|
+
[ -f "$d/kit-gc.sh" ] && . "$d/kit-gc.sh"
|
|
810
|
+
}
|
|
811
|
+
|
|
685
812
|
# _eo_source_board — lazily source the board helpers (gh-project.sh) + captured field ids so
|
|
686
813
|
# effort_close can set Status=Done from any shell, with no caller wiring (bin/cckit sources the
|
|
687
814
|
# board helpers only for `effort new`). Guarded: a no-op unless Projects v2 is on; a missing
|
|
@@ -736,7 +863,9 @@ _eo_knowledge_ingest() {
|
|
|
736
863
|
case "$hook" in /*) : ;; *) hook="$root/$hook" ;; esac # resolve a relative hook against the root
|
|
737
864
|
[ -x "$hook" ] || { echo "effort_close: knowledge-ingest hook '$hook' not executable — skipping" >&2; return 0; }
|
|
738
865
|
echo " → knowledge-ingest hook: $hook $num" >&2
|
|
739
|
-
|
|
866
|
+
# Run it from the main checkout (#371): the close has just removed the worktree it was invoked from,
|
|
867
|
+
# so the inherited cwd no longer exists and a hook's relative paths / bare git calls would fail.
|
|
868
|
+
( cd "${root:-/}" && "$hook" "$num" "$trace" ) >/dev/null 2>&1 || echo "effort_close: knowledge-ingest hook failed (non-fatal)" >&2
|
|
740
869
|
}
|
|
741
870
|
|
|
742
871
|
# effort_close <N> — the SINGLE close implementation (#148): the /kit-effort-close skill is a thin
|
|
@@ -774,7 +903,10 @@ effort_close() {
|
|
|
774
903
|
|
|
775
904
|
# (a2) refuse-squash-without-trace backstop: the squash is irreversible and collapses the per-sub
|
|
776
905
|
# commits that ARE the work record. If nothing was snapshotted, refuse — unless KIT_FORCE=1.
|
|
777
|
-
|
|
906
|
+
# index.jsonl is the marker, not the presence of a .diff: the snapshot moves it into place only
|
|
907
|
+
# after every record is written, so a non-empty index means a complete trace. The old `ls *.diff`
|
|
908
|
+
# test passed on the empty NN-.diff a collapsed run left behind (#339).
|
|
909
|
+
if [ -z "$trace_dir" ] || [ ! -s "$trace_dir/index.jsonl" ]; then
|
|
778
910
|
if [ "${KIT_FORCE:-0}" = "1" ]; then
|
|
779
911
|
echo "effort_close: no per-sub work trace captured — proceeding anyway (KIT_FORCE=1)" >&2
|
|
780
912
|
else
|
|
@@ -805,10 +937,11 @@ effort_close() {
|
|
|
805
937
|
# issue + record state are owned by this ONE op (effort-model.md) — never a separate "mark done".
|
|
806
938
|
_eo_source_board
|
|
807
939
|
local sub
|
|
808
|
-
|
|
940
|
+
while IFS= read -r sub; do
|
|
941
|
+
[ -n "$sub" ] || continue
|
|
809
942
|
gh issue close "$sub" --repo "$repo" --reason completed >/dev/null 2>&1 && echo " ✓ closed sub #$sub" >&2
|
|
810
943
|
_eo_board_done "$sub"
|
|
811
|
-
done
|
|
944
|
+
done < <(gh api "repos/$repo/issues/$num/sub_issues" --jq '.[].number' 2>/dev/null)
|
|
812
945
|
gh issue close "$num" --repo "$repo" --reason completed >/dev/null 2>&1 && echo " ✓ closed effort #$num" >&2
|
|
813
946
|
_eo_board_done "$num"
|
|
814
947
|
|
|
@@ -818,6 +951,16 @@ effort_close() {
|
|
|
818
951
|
if [ -n "$root" ]; then
|
|
819
952
|
git -C "$root" checkout "$base" >/dev/null 2>&1 || true
|
|
820
953
|
git -C "$root" pull origin "$base" --quiet >/dev/null 2>&1 || true
|
|
954
|
+
# (f2) the effort's sub worktrees + branches (#388): the squash just put their work on base, so
|
|
955
|
+
# kit_gc_prune's LANDED path deletes them — same classifier and recover-before-prune guards as
|
|
956
|
+
# `cckit cleanup` (a dirty sub worktree, or a sub ahead of its remote, stays). Runs in a subshell
|
|
957
|
+
# from the main checkout, BEFORE this worktree is removed, with the base `origin/<base>` just
|
|
958
|
+
# pulled above. A sub that fails both LANDED checks is left as an ORPHAN for `cckit gc` to show.
|
|
959
|
+
_eo_source_gc
|
|
960
|
+
if command -v kit_gc_prune >/dev/null 2>&1; then
|
|
961
|
+
( cd "$root" && KIT_GC_REPO="$repo" KIT_BASE_BRANCH="$base" kit_gc_prune --yes --only "^sub/${num}[a-z]-" 2>&1 \
|
|
962
|
+
| grep -E '^ (removed worktree|deleted local branch|SKIP)' | sed 's/^ / ✓ sub gc: /' >&2 ) || true
|
|
963
|
+
fi
|
|
821
964
|
if [ -n "$self_wt" ] && [ "$self_wt" != "$root" ]; then
|
|
822
965
|
case "$self_wt" in "$root"/.claude/worktrees/*)
|
|
823
966
|
git -C "$root" worktree remove "$self_wt" --force >/dev/null 2>&1 && echo " ✓ removed worktree $self_wt" >&2 ;;
|
|
@@ -71,9 +71,11 @@ tc "$GH_LOG" 'scripts/lib/effort-ops\.sh and skills' "body fills ## For agents"
|
|
|
71
71
|
tc "$GH_LOG" 'the verb and skill produce identical' "body fills ## Verification"
|
|
72
72
|
tn "$GH_LOG" '<!--' "no template placeholder left in a filled body"
|
|
73
73
|
|
|
74
|
-
# Label set on the parent: ctx + kind + priority + role + flow (flow lowercased).
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
# Label set on the parent: effort + ctx + kind + priority + role + flow (flow lowercased).
|
|
75
|
+
# `effort` leads: it is the one `effort_plan` queries, and it was read by that verb while nothing
|
|
76
|
+
# wrote it — so `cckit effort plan` answered "no open efforts found" on every repo.
|
|
77
|
+
tc "$GH_LOG" 'issue create .*--label effort,ctx:[SMLX]+,kind:task,priority:p2,role:tech-lead,flow:core' \
|
|
78
|
+
"parent carries effort/ctx/kind/priority/role/flow labels"
|
|
77
79
|
# Flow tag on the composed title.
|
|
78
80
|
tc "$GH_LOG" 'issue edit 1 .*--title \[Effort\] 1 · \[Core\] demo parity effort' \
|
|
79
81
|
"parent title carries the [Core] flow tag + injected number"
|
package/scripts/lib/effort.sh
CHANGED
|
@@ -80,29 +80,50 @@ effort_snapshot_subs() {
|
|
|
80
80
|
return 0
|
|
81
81
|
fi
|
|
82
82
|
|
|
83
|
-
#
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
# Split on newlines EXPLICITLY. `for sha in $shas` relied on the shell word-splitting an unquoted
|
|
84
|
+
# expansion: bash does, zsh does not. Sourced into zsh the loop ran once with every SHA as one
|
|
85
|
+
# argument, `git rev-parse --short` failed, and the run still printed "✓ snapshotted 1 commit(s)"
|
|
86
|
+
# and exited 0 — a silently collapsed work record that effort_close's no-trace backstop accepts,
|
|
87
|
+
# because the empty NN-.diff it leaves behind satisfies that check (#339).
|
|
88
|
+
local -a sha_list=()
|
|
89
|
+
local line
|
|
90
|
+
while IFS= read -r line; do
|
|
91
|
+
[[ -n "$line" ]] && sha_list+=("$line")
|
|
92
|
+
done <<EOF_SHAS
|
|
93
|
+
$shas
|
|
94
|
+
EOF_SHAS
|
|
86
95
|
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
# Build the index beside the real one and move it into place only once every record is written.
|
|
97
|
+
# Truncating index.jsonl up front made a failed re-run destroy the previous trace's pairing while
|
|
98
|
+
# leaving its NN-<short>.diff files on disk — readable bytes nothing could tie to a sub-issue.
|
|
99
|
+
local index="$dir/index.jsonl" staged="$dir/.index.jsonl.part"
|
|
100
|
+
: > "$staged"
|
|
101
|
+
|
|
102
|
+
local sha sub subj body short stub
|
|
103
|
+
for sha in "${sha_list[@]}"; do
|
|
104
|
+
short="$(git rev-parse --short "$sha" 2>/dev/null)"
|
|
105
|
+
if [[ -z "$short" ]]; then
|
|
106
|
+
echo "effort_snapshot_subs: '$sha' is not a commit — refusing to write a partial trace" >&2
|
|
107
|
+
rm -f "$staged"; return 1
|
|
108
|
+
fi
|
|
89
109
|
seq=$((seq + 1))
|
|
90
110
|
subj="$(git log -1 --format='%s' "$sha")"
|
|
91
111
|
body="$(git log -1 --format='%b' "$sha")"
|
|
92
112
|
# Last #<num> mentioned = the sub-issue this commit closes/implements (effort-model convention).
|
|
93
113
|
sub="$(printf '%s\n%s' "$subj" "$body" | grep -oE '#[0-9]+' | tail -1 | tr -d '#')"
|
|
94
|
-
|
|
95
|
-
stub="$(printf '%02d-%s' "$seq" "$(git rev-parse --short "$sha")")"
|
|
114
|
+
stub="$(printf '%02d-%s' "$seq" "$short")"
|
|
96
115
|
git show --no-color --format=fuller "$sha" > "$dir/$stub.diff" 2>/dev/null
|
|
97
|
-
# meta: commit→sub-issue pairing + outcome hint for the record.
|
|
98
|
-
|
|
116
|
+
# meta: commit→sub-issue pairing + outcome hint for the record. -c so one record is one line —
|
|
117
|
+
# index.jsonl is read line-wise by exporters, and pretty-printed records spanned ~9 lines each.
|
|
118
|
+
jq -c -n --arg parent "$parent" --arg sub "${sub:-}" --arg sha "$sha" \
|
|
99
119
|
--arg subject "$subj" --arg branch "$branch" --arg file "$stub.diff" \
|
|
100
120
|
'{parent:($parent|tonumber), sub_issue:(if $sub=="" then null else ($sub|tonumber) end),
|
|
101
121
|
commit:$sha, subject:$subject, branch:$branch, diff_file:$file, outcome:"merged"}' \
|
|
102
122
|
> "$dir/$stub.meta"
|
|
103
|
-
cat "$dir/$stub.meta" >> "$
|
|
123
|
+
cat "$dir/$stub.meta" >> "$staged"
|
|
104
124
|
done
|
|
105
125
|
|
|
126
|
+
mv "$staged" "$index"
|
|
106
127
|
echo " ✓ snapshotted $seq commit(s) to $dir (index.jsonl)" >&2
|
|
107
128
|
printf '%s' "$dir"
|
|
108
129
|
}
|
|
@@ -118,8 +139,10 @@ effort_snapshot_merged_subs() {
|
|
|
118
139
|
[[ -n "$parent" && -n "$rows" ]] || { echo "effort_snapshot_merged_subs: parent + sub rows required" >&2; return 1; }
|
|
119
140
|
dir="$(effort_trace_dir "$parent")" || { echo "effort_snapshot_merged_subs: could not create trace dir" >&2; return 1; }
|
|
120
141
|
|
|
121
|
-
|
|
122
|
-
|
|
142
|
+
# Same staged-then-moved index as effort_snapshot_subs: a failed re-run must not leave the
|
|
143
|
+
# previous trace unreadable (#339).
|
|
144
|
+
local index="$dir/index.jsonl" staged="$dir/.index.jsonl.part"
|
|
145
|
+
: > "$staged"
|
|
123
146
|
|
|
124
147
|
local sub state pr oid title stub short
|
|
125
148
|
while IFS='|' read -r sub state pr oid title; do
|
|
@@ -129,17 +152,18 @@ effort_snapshot_merged_subs() {
|
|
|
129
152
|
stub="$(printf '%02d-%s' "$seq" "$short")"
|
|
130
153
|
gh pr diff "$pr" --repo "$EFFORT_REPO" > "$dir/$stub.diff" 2>/dev/null || rm -f "$dir/$stub.diff"
|
|
131
154
|
[[ -s "$dir/$stub.diff" ]] || { rm -f "$dir/$stub.diff"; seq=$((seq - 1)); continue; }
|
|
132
|
-
jq -n --arg parent "$parent" --arg sub "${sub:-}" --arg sha "${oid:-}" \
|
|
155
|
+
jq -c -n --arg parent "$parent" --arg sub "${sub:-}" --arg sha "${oid:-}" \
|
|
133
156
|
--arg subject "$title" --arg pr "$pr" --arg file "$stub.diff" \
|
|
134
157
|
'{parent:($parent|tonumber), sub_issue:(if $sub=="" then null else ($sub|tonumber) end),
|
|
135
158
|
commit:(if $sha=="" then null else $sha end), pr:($pr|tonumber), subject:$subject,
|
|
136
159
|
branch:null, diff_file:$file, outcome:"merged"}' \
|
|
137
160
|
> "$dir/$stub.meta"
|
|
138
|
-
cat "$dir/$stub.meta" >> "$
|
|
161
|
+
cat "$dir/$stub.meta" >> "$staged"
|
|
139
162
|
done <<EOF_ROWS
|
|
140
163
|
$rows
|
|
141
164
|
EOF_ROWS
|
|
142
165
|
|
|
166
|
+
mv "$staged" "$index"
|
|
143
167
|
echo " ✓ snapshotted $seq merged sub PR diff(s) to $dir (index.jsonl)" >&2
|
|
144
168
|
printf '%s' "$dir"
|
|
145
169
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# hook-refresh-test.sh — `init --upgrade` refreshes an unmodified kit hook and reports a customized
|
|
3
|
+
# one without touching it (#370). Part 1 drives hook_refresh_state against a fixture kit repo with
|
|
4
|
+
# two template versions in its history; part 2 runs the real init.sh --upgrade on a scratch project.
|
|
5
|
+
# Run: bash scripts/lib/hook-refresh-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
fail=0
|
|
10
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
11
|
+
command -v jq >/dev/null 2>&1 || { echo "hook-refresh-test: jq required" >&2; exit 1; }
|
|
12
|
+
# shellcheck source=/dev/null
|
|
13
|
+
. "$ROOT/scripts/lib/hook-refresh.sh"
|
|
14
|
+
|
|
15
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
16
|
+
g() { git -C "$1" -c user.email=t@t -c user.name=t "${@:2}"; }
|
|
17
|
+
|
|
18
|
+
# ── part 1: the verdicts, against a fixture kit with template history v1 → v2 ─────────────────
|
|
19
|
+
kit="$tmp/kit"; git init -q "$kit"; mkdir -p "$kit/templates/hooks"
|
|
20
|
+
tpl="$kit/templates/hooks/h.sh.tmpl"
|
|
21
|
+
printf '#!/usr/bin/env bash\necho v1\n' > "$tpl"; g "$kit" add -A; g "$kit" commit -q -m v1
|
|
22
|
+
printf '#!/usr/bin/env bash\necho v2\n' > "$tpl"; g "$kit" commit -qam v2
|
|
23
|
+
inst="$tmp/installed.sh"
|
|
24
|
+
|
|
25
|
+
printf '#!/usr/bin/env bash\necho v2\n' > "$inst"
|
|
26
|
+
t "the current template is current" "$(hook_refresh_state "$inst" "$tpl" "$kit")" current
|
|
27
|
+
printf '#!/usr/bin/env bash\necho v1\n' > "$inst"
|
|
28
|
+
t "an older shipped version is refreshable" "$(hook_refresh_state "$inst" "$tpl" "$kit")" refresh
|
|
29
|
+
printf '#!/usr/bin/env bash\necho v1\n# mine\n' > "$inst"
|
|
30
|
+
t "a customized copy is drifted" "$(hook_refresh_state "$inst" "$tpl" "$kit")" drifted
|
|
31
|
+
t "no kit history (npm/brew): drifted" "$(hook_refresh_state "$inst" "$tpl" "$tmp/no-git")" drifted
|
|
32
|
+
mf="$tmp/kit.manifest.json"
|
|
33
|
+
printf '{"schema":1,"entries":{".claude/hooks/h.sh":{"hash":"%s"}}}\n' "$(_hr_hash_file "$inst")" > "$mf"
|
|
34
|
+
t "the manifest hash proves it unmodified" "$(hook_refresh_state "$inst" "$tpl" "$tmp/no-git" "$mf" .claude/hooks/h.sh)" refresh
|
|
35
|
+
t "a missing hook is missing" "$(hook_refresh_state "$tmp/nope" "$tpl" "$kit")" missing
|
|
36
|
+
g "$kit" mv templates/hooks/h.sh.tmpl templates/hooks/renamed.sh.tmpl; g "$kit" commit -qm rename
|
|
37
|
+
t "history follows a renamed template" "$(hook_refresh_state "$inst" "$kit/templates/hooks/renamed.sh.tmpl" "$kit" 2>/dev/null; printf '#!/usr/bin/env bash\necho v1\n' > "$inst"; hook_refresh_state "$inst" "$kit/templates/hooks/renamed.sh.tmpl" "$kit")" "drifted
|
|
38
|
+
refresh"
|
|
39
|
+
|
|
40
|
+
# ── part 2: the real init.sh --upgrade ───────────────────────────────────────────────────────────
|
|
41
|
+
proj="$tmp/proj"; git init -q "$proj"; g "$proj" commit -q --allow-empty -m init
|
|
42
|
+
mkdir -p "$proj/.claude/hooks"
|
|
43
|
+
printf '{"kitVersion":"0.0.1","profile":"software","project":{"name":"H","slug":"h"},"github":{"repo":"e/h","owner":"e","projectsV2":false}}\n' > "$proj/.claude/kit.config.json"
|
|
44
|
+
up() { CLAUDE_PLUGIN_ROOT="$ROOT" bash "$ROOT/scripts/init.sh" --upgrade --target "$proj" --force 2>&1; }
|
|
45
|
+
up >/dev/null || { echo "FAIL: first init.sh --upgrade"; fail=1; }
|
|
46
|
+
|
|
47
|
+
old="$proj/.claude/hooks/guard-base-branch-commit.sh" # unmodified, but an OLDER kit version
|
|
48
|
+
own="$proj/.claude/hooks/repo-hygiene.sh" # customized by the project
|
|
49
|
+
printf '#!/usr/bin/env bash\n# an older kit version of this hook\nexit 0\n' > "$old"
|
|
50
|
+
( cd "$proj" && KIT_MANIFEST="$proj/.claude/kit.manifest.json" bash -c '
|
|
51
|
+
. "$1/scripts/lib/kit-manifest.sh"; kit_manifest_init; kit_manifest_record .claude/hooks/guard-base-branch-commit.sh B init >/dev/null' _ "$ROOT" )
|
|
52
|
+
printf '\n# project-specific tweak\n' >> "$own"
|
|
53
|
+
own_before="$(cat "$own")"
|
|
54
|
+
|
|
55
|
+
# A template fix ships with a new kit version: rewind kitVersion so the upgrade runs again.
|
|
56
|
+
jq '.kitVersion = "0.0.1"' "$proj/.claude/kit.config.json" > "$tmp/cfg" && mv "$tmp/cfg" "$proj/.claude/kit.config.json"
|
|
57
|
+
out="$(up)"
|
|
58
|
+
t "the unmodified hook now equals the template" "$(cmp -s "$old" "$ROOT/templates/hooks/guard-base-branch-commit.sh.tmpl" && echo same || echo differs)" same
|
|
59
|
+
case "$out" in *"~ .claude/hooks/guard-base-branch-commit.sh"*) echo "ok: the refresh is reported" ;; *) echo "FAIL: refresh not reported"; fail=1 ;; esac
|
|
60
|
+
t "the customized hook is untouched" "$(cat "$own")" "$own_before"
|
|
61
|
+
case "$out" in *"! .claude/hooks/repo-hygiene.sh"*) echo "ok: the customized hook is reported as drifted" ;; *) echo "FAIL: drift not reported"; fail=1 ;; esac
|
|
62
|
+
case "$out" in *"= .claude/hooks/guard-raw-git-ops.sh"*) echo "ok: a current hook is just preserved" ;; *) echo "FAIL: current hook not listed as preserved"; fail=1 ;; esac
|
|
63
|
+
|
|
64
|
+
[ "$fail" -eq 0 ] && echo "hook-refresh: all passed" || echo "hook-refresh: FAILURES"
|
|
65
|
+
exit "$fail"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# hook-refresh.sh — tell an unmodified kit hook from a customized one, so `init --upgrade` can
|
|
4
|
+
# refresh the first and only report the second (#370).
|
|
5
|
+
#
|
|
6
|
+
# `init --upgrade` preserves every existing file. That protects a customized hook, but it also
|
|
7
|
+
# froze unmodified ones: a hook installed from a template never received later template fixes.
|
|
8
|
+
#
|
|
9
|
+
# hook_refresh_state <installed> <template> <kit-root> [manifest] [rel]
|
|
10
|
+
# prints one word:
|
|
11
|
+
# current the installed hook already equals the template
|
|
12
|
+
# refresh it equals an EARLIER version of the template (from <kit-root>'s git history,
|
|
13
|
+
# following renames), or the hash the manifest recorded for <rel> — unmodified,
|
|
14
|
+
# safe to overwrite
|
|
15
|
+
# drifted it matches no version the kit shipped — the repo customized it; keep it, report it
|
|
16
|
+
# missing no installed file
|
|
17
|
+
#
|
|
18
|
+
# Templates with {{VARS}} or IF blocks are rendered per project, so their history cannot be
|
|
19
|
+
# compared byte for byte; for those only the manifest can prove a file unmodified.
|
|
20
|
+
# Requires git, plus shasum or sha256sum.
|
|
21
|
+
# errors: pure — prints a verdict, rc 0
|
|
22
|
+
# bash 3.2 + zsh compatible.
|
|
23
|
+
|
|
24
|
+
_hr_hash_file() {
|
|
25
|
+
if command -v shasum >/dev/null 2>&1; then shasum -a 256 < "$1" | awk '{print $1}'
|
|
26
|
+
else sha256sum < "$1" | awk '{print $1}'; fi
|
|
27
|
+
}
|
|
28
|
+
_hr_hash_stdin() {
|
|
29
|
+
if command -v shasum >/dev/null 2>&1; then shasum -a 256 | awk '{print $1}'
|
|
30
|
+
else sha256sum | awk '{print $1}'; fi
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# _hr_history_hashes <kit-root> <template> — the hash of every committed version of <template>,
|
|
34
|
+
# one per line, following renames. Prints nothing when <kit-root> is not a git checkout (an npm or
|
|
35
|
+
# Homebrew install), which leaves only the manifest as evidence.
|
|
36
|
+
_hr_history_hashes() {
|
|
37
|
+
local root="$1" tpl="$2" rel line c=""
|
|
38
|
+
rel="${tpl#"$root"/}"
|
|
39
|
+
git -C "$root" rev-parse --git-dir >/dev/null 2>&1 || return 0
|
|
40
|
+
git -C "$root" log --follow --format='C %H' --name-only -- "$rel" 2>/dev/null | while IFS= read -r line; do
|
|
41
|
+
case "$line" in
|
|
42
|
+
"C "*) c="${line#C }" ;;
|
|
43
|
+
"") : ;;
|
|
44
|
+
*) [ -n "$c" ] && git -C "$root" show "$c:$line" 2>/dev/null | _hr_hash_stdin ;;
|
|
45
|
+
esac
|
|
46
|
+
done
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
hook_refresh_state() {
|
|
50
|
+
local inst="$1" tpl="$2" root="$3" mf="${4:-}" rel="${5:-}" cur h
|
|
51
|
+
[ -f "$inst" ] || { echo missing; return 0; }
|
|
52
|
+
cur="$(_hr_hash_file "$inst")"
|
|
53
|
+
if [ "$cur" = "$(_hr_hash_file "$tpl")" ]; then echo current; return 0; fi
|
|
54
|
+
if [ -n "$mf" ] && [ -n "$rel" ] && [ -f "$mf" ] && command -v jq >/dev/null 2>&1; then
|
|
55
|
+
h="$(jq -r --arg r "$rel" '.entries[$r].hash // empty' "$mf" 2>/dev/null)"
|
|
56
|
+
[ -n "$h" ] && [ "$h" = "$cur" ] && { echo refresh; return 0; }
|
|
57
|
+
fi
|
|
58
|
+
if ! grep -qE '\{\{[A-Za-z_]+\}\}|<!-- IF:' "$tpl" 2>/dev/null; then
|
|
59
|
+
if _hr_history_hashes "$root" "$tpl" | grep -qx "$cur"; then echo refresh; return 0; fi
|
|
60
|
+
fi
|
|
61
|
+
echo drifted
|
|
62
|
+
}
|
|
@@ -86,6 +86,12 @@ load_kit_config() {
|
|
|
86
86
|
# back to its built-in default of 2. An EFFORT_WIP_LIMIT env var still wins per invocation.
|
|
87
87
|
export KIT_EFFORT_WIP_LIMIT="$(jq -r 'if (.effort.wipLimit | type) == "null" then "" else (.effort.wipLimit | tostring) end' "$cfg")"
|
|
88
88
|
|
|
89
|
+
# PR conventions (#361). pr.titleStyle: "conventional" (default — release-please + commitlint read
|
|
90
|
+
# the squash subject) or "issue-title" (the PR title is the issue title, verbatim).
|
|
91
|
+
# pr.orchestratorSection: true adds a 2-line `## For the orchestrator` section to `cckit pr` bodies.
|
|
92
|
+
export KIT_PR_TITLE_STYLE="$(jq -r '.pr.titleStyle // "conventional"' "$cfg")"
|
|
93
|
+
export KIT_PR_ORCHESTRATOR_SECTION="$(jq -r '.pr.orchestratorSection // false' "$cfg")"
|
|
94
|
+
|
|
89
95
|
# Apply per-folder .claudekit/ overrides (no-op when none exist).
|
|
90
96
|
_kit_apply_claudekit_overlays "$cfg"
|
|
91
97
|
}
|