@jeiemgi/cckit 0.10.0 → 0.12.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 +136 -127
- package/README.md +66 -43
- package/bin/cckit +151 -181
- package/cckit.config.json +1 -4
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot-run-test.sh +20 -12
- package/scripts/autopilot-run.sh +9 -1
- package/scripts/autopilot-test.sh +29 -13
- package/scripts/autopilot.sh +4 -4
- package/scripts/benchmark/verb-timings-test.sh +4 -0
- package/scripts/benchmark/verb-timings.sh +16 -5
- package/scripts/capture-project-ids.sh +23 -1
- package/scripts/check.sh +25 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/contribute.sh +8 -3
- package/scripts/copilot-loop-test.sh +66 -81
- package/scripts/exec-targets-test.sh +20 -0
- package/scripts/force-push-fence-test.sh +44 -0
- package/scripts/force-push-fence.baseline +1 -0
- package/scripts/force-push-fence.sh +51 -0
- package/scripts/forge-fence-test.sh +69 -0
- package/scripts/forge-fence.baseline +2 -0
- package/scripts/forge-fence.sh +76 -0
- package/scripts/forge-report-test.sh +100 -0
- package/scripts/forge-report.sh +176 -0
- package/scripts/init-guided-test.sh +94 -82
- package/scripts/init.sh +12 -7
- package/scripts/install-test.sh +26 -0
- package/scripts/install.sh +7 -0
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +60 -12
- package/scripts/kit-doctor.sh +170 -77
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +15 -8
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +37 -8
- package/scripts/lib/content-kinds-gc-test.sh +22 -21
- package/scripts/lib/copilot-test.sh +20 -11
- package/scripts/lib/copilot.sh +19 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +5 -3
- package/scripts/lib/effort-metrics-test.sh +7 -12
- package/scripts/lib/effort-metrics.sh +17 -46
- package/scripts/lib/effort-ops-test.sh +261 -167
- package/scripts/lib/effort-ops.sh +449 -171
- package/scripts/lib/effort-parity-test.sh +57 -62
- package/scripts/lib/effort-plan-test.sh +56 -54
- package/scripts/lib/effort-plan.sh +14 -7
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +34 -14
- package/scripts/lib/effort-slug.sh +13 -13
- package/scripts/lib/effort.sh +58 -80
- package/scripts/lib/forge-github.sh +260 -0
- package/scripts/lib/forge-none.sh +24 -0
- package/scripts/lib/forge-test.sh +186 -0
- package/scripts/lib/forge.sh +133 -0
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +151 -31
- package/scripts/lib/gh-project.sh +139 -11
- package/scripts/lib/gh-rest-test.sh +63 -118
- package/scripts/lib/gh-rest.sh +275 -52
- package/scripts/lib/git-core-test.sh +128 -0
- package/scripts/lib/grill-record-test.sh +49 -0
- package/scripts/lib/grill-record.sh +88 -0
- package/scripts/lib/handoff.sh +1 -1
- package/scripts/lib/init-github.sh +38 -13
- package/scripts/lib/kinds-test.sh +13 -16
- package/scripts/lib/kit-brief-test.sh +51 -10
- package/scripts/lib/kit-brief.sh +103 -18
- package/scripts/lib/kit-gc-test.sh +90 -109
- package/scripts/lib/kit-gc.sh +19 -22
- package/scripts/lib/kit-hotfix.sh +18 -16
- package/scripts/lib/kit-interview.sh +6 -0
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +7 -7
- package/scripts/lib/kit-msg.sh +3 -3
- package/scripts/lib/kit-status.sh +19 -14
- package/scripts/lib/kit-task-ops-test.sh +20 -1
- package/scripts/lib/kit-task-ops.sh +177 -94
- package/scripts/lib/kto-hotfix-test.sh +53 -58
- package/scripts/lib/kto-task-close-test.sh +28 -27
- package/scripts/lib/kto-task-new-test.sh +55 -48
- package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
- package/scripts/lib/kto-task-pr-test.sh +30 -34
- package/scripts/lib/light-task-run-test.sh +19 -15
- package/scripts/lib/light-task-test.sh +34 -29
- package/scripts/lib/light-task.sh +24 -13
- package/scripts/lib/loose-issues.sh +65 -0
- package/scripts/lib/naming-test.sh +112 -0
- package/scripts/lib/naming-verbs-test.sh +126 -0
- package/scripts/lib/naming.sh +172 -0
- package/scripts/lib/next-test.sh +27 -22
- package/scripts/lib/next.sh +13 -7
- package/scripts/lib/orchestration-runtime-test.sh +11 -8
- package/scripts/lib/plan-machine.sh +22 -16
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +63 -74
- package/scripts/lib/pr-evidence.sh +15 -12
- package/scripts/lib/qa-lane-test.sh +59 -27
- package/scripts/lib/qa-lane.sh +14 -6
- package/scripts/lib/review-page-test.sh +34 -25
- package/scripts/lib/review-page.sh +10 -4
- package/scripts/lib/spec-lint-test.sh +63 -0
- package/scripts/lib/spec-lint.sh +95 -0
- package/scripts/lib/sprint-test.sh +96 -0
- package/scripts/lib/sprint.sh +216 -0
- package/scripts/lib/stage-receipt-test.sh +169 -19
- package/scripts/lib/stage-receipt.sh +195 -10
- package/scripts/lib/test-forge-shim.sh +115 -0
- package/scripts/lib/verbs.sh +105 -0
- package/scripts/lib/verbs.tsv +92 -0
- package/scripts/lib/version-bump-test.sh +20 -0
- package/scripts/lib/version-bump.sh +4 -2
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-issue-test.sh +24 -19
- package/scripts/lib/worktree-issue.sh +10 -10
- package/scripts/lib/worktree-start-test.sh +13 -16
- package/scripts/lib/worktree-start.sh +57 -7
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/marketing-walkthrough-test.sh +25 -30
- package/scripts/night-grant.sh +14 -8
- package/scripts/night-run.mjs +1 -1
- package/scripts/orchestrate-test.sh +27 -31
- package/scripts/orchestrate.sh +9 -3
- package/scripts/portable-test.sh +37 -36
- package/scripts/publish.sh +9 -3
- package/scripts/setup-labels.sh +23 -12
- package/scripts/setup-milestones.sh +8 -2
- package/scripts/status-test.sh +39 -33
- package/scripts/status.sh +12 -6
- package/scripts/task-sync-test.sh +75 -32
- package/scripts/task-sync.sh +97 -6
- package/scripts/terms-check-test.sh +191 -0
- package/scripts/terms-check.sh +242 -0
- package/scripts/verbs-gen.sh +43 -0
- package/scripts/verbs-help-test.sh +61 -0
- package/scripts/verbs-ratchet-test.sh +69 -0
- package/scripts/verbs-ratchet.sh +34 -0
- package/scripts/verbs-test.sh +120 -0
- package/scripts/verbs.baseline +5 -0
- package/skills/kit-add/SKILL.md +2 -1
- package/skills/kit-advisor/SKILL.md +75 -0
- package/skills/kit-advisor/references/close.md +53 -0
- package/skills/kit-advisor/references/grill.md +69 -0
- package/skills/kit-advisor/references/orchestrate.md +56 -0
- package/skills/kit-advisor/references/plan.md +64 -0
- package/skills/kit-advisor/references/review.md +47 -0
- package/skills/kit-advisor/references/step-report.md +61 -0
- package/skills/kit-annotate/SKILL.md +1 -0
- package/skills/kit-autopilot/SKILL.md +2 -1
- package/skills/kit-cleanup/SKILL.md +3 -2
- package/skills/kit-contribute/SKILL.md +1 -0
- package/skills/kit-customize/SKILL.md +1 -0
- package/skills/kit-dev/SKILL.md +1 -0
- package/skills/kit-digest/SKILL.md +1 -0
- package/skills/kit-docs-writer/SKILL.md +4 -3
- package/skills/kit-effort-close/SKILL.md +18 -9
- package/skills/kit-effort-new/SKILL.md +12 -8
- package/skills/kit-effort-pr/SKILL.md +8 -7
- package/skills/kit-effort-start/SKILL.md +1 -0
- package/skills/kit-gc/SKILL.md +1 -0
- package/skills/kit-next/SKILL.md +8 -7
- package/skills/kit-onboard/SKILL.md +1 -0
- package/skills/kit-page/SKILL.md +1 -0
- package/skills/kit-plan-next/SKILL.md +11 -11
- package/skills/kit-security-sweep/SKILL.md +1 -0
- package/skills/kit-ship/SKILL.md +1 -0
- package/skills/kit-status/SKILL.md +6 -5
- package/skills/kit-task-close/SKILL.md +1 -0
- package/skills/kit-task-new/SKILL.md +1 -0
- package/skills/kit-task-pr/SKILL.md +1 -0
- package/skills/kit-task-pr-auto/SKILL.md +2 -1
- package/skills/kit-task-pr-merge/SKILL.md +4 -3
- package/skills/kit-task-start/SKILL.md +1 -0
- package/skills/kit-task-sync/SKILL.md +3 -0
- package/skills/kit-ux-audit/SKILL.md +1 -0
- package/skills/routing.yaml +124 -0
- package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
- package/templates/instructions.md.tmpl +3 -3
- package/templates/rules/authoring.md +7 -3
- package/templates/rules/delegation-brief.md +4 -0
- package/templates/rules/effort-model.md +34 -31
- package/templates/rules/gate-and-review.md +1 -1
- package/templates/rules/merge-safety.md +9 -7
- package/templates/rules/naming-and-ids.md +20 -24
- package/templates/rules/plan-next.md +5 -5
- package/templates/skills/campaign/SKILL.md +2 -2
- package/scripts/lib/engine-adapter.sh +0 -93
|
@@ -34,6 +34,12 @@
|
|
|
34
34
|
# errors: strict — rc 1 on any failed step; nothing is pushed or opened after a failure
|
|
35
35
|
# Runs under the dispatcher's `set -eu`: every read that may fail carries `|| true` or an `if`.
|
|
36
36
|
|
|
37
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
38
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
39
|
+
# shellcheck source=/dev/null
|
|
40
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
41
|
+
fi
|
|
42
|
+
|
|
37
43
|
_LT_LIB_DIR="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)"
|
|
38
44
|
if ! command -v task_source_call >/dev/null 2>&1; then
|
|
39
45
|
# shellcheck source=task-source.sh
|
|
@@ -48,6 +54,10 @@ if ! type cckit_gh_rest >/dev/null 2>&1; then
|
|
|
48
54
|
[ -f "$_LT_LIB_DIR/gh-rest.sh" ] && . "$_LT_LIB_DIR/gh-rest.sh"
|
|
49
55
|
fi
|
|
50
56
|
type cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
57
|
+
if ! type naming_title_lint >/dev/null 2>&1; then
|
|
58
|
+
# shellcheck source=naming.sh
|
|
59
|
+
[ -f "$_LT_LIB_DIR/naming.sh" ] && . "$_LT_LIB_DIR/naming.sh"
|
|
60
|
+
fi
|
|
51
61
|
type cckit_is_json >/dev/null 2>&1 || cckit_is_json() { [ "${CCKIT_OUTPUT:-human}" = "json" ]; }
|
|
52
62
|
|
|
53
63
|
_LT_TAB="$(printf '\t')"
|
|
@@ -304,23 +314,13 @@ _lt_open_pr() {
|
|
|
304
314
|
echo "✗ could not push $branch — the commit is kept in $wt; run the same command again to retry" >&2
|
|
305
315
|
return 1
|
|
306
316
|
fi
|
|
307
|
-
|
|
308
|
-
n="$(gh_rest_pr_for_head "$repo" "$branch" 2>/dev/null || true)"
|
|
309
|
-
if [ -n "$n" ]; then url="https://github.com/$repo/pull/$n"; fi
|
|
310
|
-
else
|
|
311
|
-
url="$(gh pr list --repo "$repo" --head "$branch" --state open --json url --jq '.[0].url // empty' 2>/dev/null || true)"
|
|
312
|
-
fi
|
|
317
|
+
url="$(gh_rest_pr_url_for_head "$repo" "$branch" 2>/dev/null || true)"
|
|
313
318
|
if [ -n "$url" ]; then
|
|
314
319
|
_lt_say "[task] a pull request is already open for $branch" \
|
|
315
320
|
"[task] this draft is already waiting for review" >&2
|
|
316
321
|
echo "✓ $url"; return 0
|
|
317
322
|
fi
|
|
318
|
-
|
|
319
|
-
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$title" "$body" "" "")" || url=""
|
|
320
|
-
else
|
|
321
|
-
url="$(gh pr create --repo "$repo" --base "$base" --head "$branch" \
|
|
322
|
-
--title "$title" --body "$body" --assignee "@me")" || url=""
|
|
323
|
-
fi
|
|
323
|
+
url="$(gh_rest_pr_create "$repo" "$base" "$branch" "$title" "$body" "" "")" || url=""
|
|
324
324
|
if [ -z "$url" ]; then
|
|
325
325
|
echo "✗ could not open the pull request for $branch — the branch is pushed; run the same command again to retry" >&2
|
|
326
326
|
return 1
|
|
@@ -609,6 +609,11 @@ _lt_share_body() {
|
|
|
609
609
|
"$(printf '%s\n' "$1" | sed 's/^/- `/; s/$/`/')" "$2"
|
|
610
610
|
}
|
|
611
611
|
|
|
612
|
+
# _lt_share_title <count> <stamp> — the share pull request's title.
|
|
613
|
+
_lt_share_title() {
|
|
614
|
+
printf 'chore(tasks): add %s task%s [share-%s]' "$1" "$([ "$1" -eq 1 ] || echo s)" "$2"
|
|
615
|
+
}
|
|
616
|
+
|
|
612
617
|
lt_share() {
|
|
613
618
|
local summary="" a root from base base_ref stamp branch wt ids n pr_title body rows
|
|
614
619
|
for a in "$@"; do
|
|
@@ -646,6 +651,12 @@ lt_share() {
|
|
|
646
651
|
if git -C "$root" show-ref --verify --quiet "refs/remotes/origin/$base"; then base_ref="origin/$base"
|
|
647
652
|
else echo "✗ task share: origin has no branch '$base'" >&2; return 1; fi
|
|
648
653
|
stamp="$(date +%Y%m%d%H%M%S)"
|
|
654
|
+
# The naming rule (E546.1), before the worktree, the commit and the PR: the share title is the one
|
|
655
|
+
# documented exception to the token rule, `[share-<stamp>]` in place of an issue's token.
|
|
656
|
+
pr_title="$(_lt_share_title "$n" "$stamp")"
|
|
657
|
+
if type naming_title_lint >/dev/null 2>&1; then
|
|
658
|
+
naming_title_lint pr "$pr_title" || { echo "✗ task share: the title '$pr_title' breaks the naming rule — nothing was written" >&2; return 1; }
|
|
659
|
+
fi
|
|
649
660
|
branch="light/share-$stamp"
|
|
650
661
|
wt="$root/.claude/worktrees/light+share-$stamp"
|
|
651
662
|
git -C "$root" worktree add --no-track -b "$branch" "$wt" "$base_ref" >/dev/null 2>&1 \
|
|
@@ -657,7 +668,7 @@ lt_share() {
|
|
|
657
668
|
git -C "$root" branch -D "$branch" >/dev/null 2>&1 || true
|
|
658
669
|
echo "(no drafts to share: the task files here are already tracked by git)"; return 0
|
|
659
670
|
fi
|
|
660
|
-
pr_title="
|
|
671
|
+
pr_title="$(_lt_share_title "$n" "$stamp")"
|
|
661
672
|
git -C "$wt" commit -q -m "$pr_title" >&2 || { echo "✗ task share: the commit failed in $wt" >&2; return 1; }
|
|
662
673
|
body="$(_lt_share_body "$ids" "${summary:-Adds $n task(s) to the list.}")"
|
|
663
674
|
echo "[task] moved $n draft(s) onto $branch — 'cckit task list' shows them as shared until the pull request merges" >&2
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# loose-issues.sh — count the open issues that belong to no unit of work (E546.2). A loose issue is
|
|
4
|
+
# an open issue (not a pull request) that is not an effort (`effort` label), not a sub-issue (the
|
|
5
|
+
# REST field `parent_issue_url` is set), and not on the board with Status = Backlog. The Backlog
|
|
6
|
+
# marker is the board's Status column; with the board off (`github.projectsV2: false`) no issue can
|
|
7
|
+
# carry it, so every standalone issue counts.
|
|
8
|
+
#
|
|
9
|
+
# loose_board_on [cfg] rc 0 iff the config turns the board on (projectsV2 true + a number)
|
|
10
|
+
# loose_repo [cfg] owner/name: .github.repo, else the origin remote; rc 1 when neither
|
|
11
|
+
# loose_issues_list <repo> [cfg] `N<TAB>title` per loose issue, ascending; rc 1 when the read failed
|
|
12
|
+
# loose_baseline_read <file> the first number in the baseline file (lines starting # are notes)
|
|
13
|
+
#
|
|
14
|
+
# Every GitHub read goes through the forge (forge_rest). Reads only; nothing is moved or relabelled.
|
|
15
|
+
# bash 3.2 + zsh compatible. Requires jq.
|
|
16
|
+
# errors: strict — a failed forge read is rc 1 and is never reported as zero loose issues
|
|
17
|
+
_loose_self="${BASH_SOURCE[0]:-$0}"
|
|
18
|
+
LOOSE_LIB="$(cd "$(dirname "$_loose_self")" && pwd)"
|
|
19
|
+
unset _loose_self
|
|
20
|
+
command -v forge_rest >/dev/null 2>&1 || . "$LOOSE_LIB/forge.sh"
|
|
21
|
+
command -v kit_config_path >/dev/null 2>&1 || . "$LOOSE_LIB/config-path.sh"
|
|
22
|
+
|
|
23
|
+
_loose_cfg() { [ -n "${1:-}" ] && { printf '%s' "$1"; return 0; }; kit_config_path 2>/dev/null; }
|
|
24
|
+
|
|
25
|
+
loose_board_on() {
|
|
26
|
+
local cfg; cfg="$(_loose_cfg "${1:-}")" || return 1
|
|
27
|
+
[ -f "$cfg" ] || return 1
|
|
28
|
+
[ "$(jq -r '(.github.projectsV2 // false) and (.github.projectNumber != null)' "$cfg" 2>/dev/null)" = true ]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
loose_repo() {
|
|
32
|
+
local cfg r=""
|
|
33
|
+
cfg="$(_loose_cfg "${1:-}")" || cfg=""
|
|
34
|
+
[ -n "$cfg" ] && [ -f "$cfg" ] && r="$(jq -r '.github.repo // empty' "$cfg" 2>/dev/null)"
|
|
35
|
+
[ -n "$r" ] || r="$(forge_repo_from_git "$(dirname "${cfg:-.}")" 2>/dev/null)" || r=""
|
|
36
|
+
[ -n "$r" ] || return 1
|
|
37
|
+
printf '%s' "$r"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
loose_issues_list() {
|
|
41
|
+
local repo="$1" cfg="${2:-}" raw n title st pnum=""
|
|
42
|
+
raw="$(forge_rest "repos/$repo/issues?state=open&per_page=100" --paginate \
|
|
43
|
+
--jq '.[] | select(.pull_request == null)
|
|
44
|
+
| select(([.labels[]?.name] | index("effort")) | not)
|
|
45
|
+
| select((.parent_issue_url // "") == "")
|
|
46
|
+
| "\(.number)\t\(.title)"')" || return 1
|
|
47
|
+
[ -n "$raw" ] || return 0
|
|
48
|
+
if loose_board_on "$cfg"; then
|
|
49
|
+
# The board holds the Backlog marker: one cheap issue.projectItems read per standalone issue.
|
|
50
|
+
command -v project_issue_status >/dev/null 2>&1 || . "$LOOSE_LIB/gh-project.sh"
|
|
51
|
+
pnum="$(jq -r '.github.projectNumber' "$(_loose_cfg "$cfg")")"
|
|
52
|
+
printf '%s\n' "$raw" | while IFS="$(printf '\t')" read -r n title; do
|
|
53
|
+
[ -n "$n" ] || continue
|
|
54
|
+
st="$(KIT_REPO="$repo" project_issue_status "$n" "$pnum" 2>/dev/null)" || st=""
|
|
55
|
+
[ "$st" = "Backlog" ] || printf '%s\t%s\n' "$n" "$title"
|
|
56
|
+
done | sort -n
|
|
57
|
+
else
|
|
58
|
+
printf '%s\n' "$raw" | sort -n
|
|
59
|
+
fi
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
loose_baseline_read() {
|
|
63
|
+
[ -f "$1" ] || return 1
|
|
64
|
+
grep -v '^#' "$1" | grep -E '^[0-9]+$' | sed -n 1p
|
|
65
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# naming-test.sh — the one title convention (scripts/lib/naming.sh, E546.1): accept/reject tables
|
|
3
|
+
# per kind, the token parser, the prefix strip over new and legacy titles, and the wrappers
|
|
4
|
+
# effort_title_lint / effort_pr_title_check that keep legacy titles valid. Hermetic, no network.
|
|
5
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
6
|
+
set -u
|
|
7
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
+
fail=0
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
. "$LIB/naming.sh"
|
|
11
|
+
|
|
12
|
+
t() { if [ "$2" = "$3" ]; then echo "ok $1"; else echo "FAIL $1"; echo " got: [$2]"; echo " want: [$3]"; fail=1; fi; }
|
|
13
|
+
acc() { if naming_title_lint "$1" "$2" >/dev/null 2>&1; then echo "ok $1 accepts: $2"; else echo "FAIL $1 should accept: $2"; naming_title_lint "$1" "$2"; fail=1; fi; }
|
|
14
|
+
rej() { if naming_title_lint "$1" "$2" >/dev/null 2>&1; then echo "FAIL $1 should reject: $2"; fail=1; else echo "ok $1 rejects: $2"; fi; }
|
|
15
|
+
|
|
16
|
+
# --- effort ---
|
|
17
|
+
acc effort "[E545] Every verb answers a question"
|
|
18
|
+
acc effort "[E12] [UI] operator navigation" # a [Flow] tag is tolerated
|
|
19
|
+
acc effort "[Effort] 12 · effort planning conventions" # legacy
|
|
20
|
+
acc effort "[Effort] 12 · [Core] operator navigation" # legacy with a flow tag
|
|
21
|
+
rej effort "Every verb answers a question" # no prefix
|
|
22
|
+
rej effort "[E545.1] a sub title is not an effort"
|
|
23
|
+
rej effort "[E545] operator chrome — Settings ▾ dropdown"
|
|
24
|
+
rej effort "[E545] refactor the thing" # jargon
|
|
25
|
+
rej effort "[E545] one two three four five six seven" # 7 words
|
|
26
|
+
rej effort "[E545] fix effort_new (the parser)" # snake_case + parens
|
|
27
|
+
rej effort "[E545] [Growth] faster onboarding" # flow outside the vocabulary
|
|
28
|
+
rej effort "[E545] " # empty name
|
|
29
|
+
|
|
30
|
+
# --- sub ---
|
|
31
|
+
acc sub "[E545.1] One naming convention for titles"
|
|
32
|
+
acc sub "[Effort 12] 4 · module tables" # legacy
|
|
33
|
+
rej sub "[E545] not a sub"
|
|
34
|
+
rej sub "[Effort 12] 4 · Section tables — columns + joins (contract B)"
|
|
35
|
+
rej sub "module tables"
|
|
36
|
+
|
|
37
|
+
# --- standalone issue ---
|
|
38
|
+
acc issue "Start accepts the effort token"
|
|
39
|
+
rej issue "[E545] an effort title is not an issue"
|
|
40
|
+
rej issue "[Core] a tag is a prefix"
|
|
41
|
+
rej issue "one two three four five six seven"
|
|
42
|
+
rej issue "update scripts/lib/naming.sh"
|
|
43
|
+
|
|
44
|
+
# --- pull request ---
|
|
45
|
+
acc pr "feat(core): one naming convention [E546]"
|
|
46
|
+
acc pr "feat(core): one naming convention for titles [E546.1]"
|
|
47
|
+
acc pr "fix(start): plant no empty lockfile [#255]"
|
|
48
|
+
acc pr "chore(tasks): add 3 tasks [share-20261124101500]" # the task share exception
|
|
49
|
+
rej pr "feat(core): no token at all"
|
|
50
|
+
rej pr "feat(core): token in the middle [#12] then words"
|
|
51
|
+
rej pr "One naming convention [E546]" # not conventional
|
|
52
|
+
rej pr "feat: parenthesis is the PR slot (E546)"
|
|
53
|
+
rej pr "chore(tasks): add 3 tasks [share-abc]"
|
|
54
|
+
if KIT_PR_TITLE_STYLE=issue-title naming_title_lint pr "[Tech Lead] [#115] adoption hardening" 2>/dev/null; then
|
|
55
|
+
echo "ok pr under issue-title style is not held to the conventional form"
|
|
56
|
+
else echo "FAIL pr under issue-title style"; fail=1; fi
|
|
57
|
+
naming_title_lint bogus "x" 2>/dev/null; t "an unknown kind is a usage error" "$?" "2"
|
|
58
|
+
naming_title_lint pr "" 2>/dev/null; t "an empty title is a usage error" "$?" "2"
|
|
59
|
+
_err="$(naming_title_lint effort "[E1] refactor one two three four five six" 2>&1 >/dev/null)"
|
|
60
|
+
case "$_err" in *"jargon word 'refactor'"*"7 words"*) echo "ok every failed rule is named on stderr" ;;
|
|
61
|
+
*) echo "FAIL reasons on stderr: $_err"; fail=1 ;; esac
|
|
62
|
+
|
|
63
|
+
# --- composers ---
|
|
64
|
+
t "effort title" "$(naming_effort_title 545 'Every verb answers a question')" "[E545] Every verb answers a question"
|
|
65
|
+
t "sub title" "$(naming_sub_title 545 2 'Start takes a token')" "[E545.2] Start takes a token"
|
|
66
|
+
t "a #-prefixed number" "$(naming_effort_title '#7' x)" "[E7] x"
|
|
67
|
+
|
|
68
|
+
# --- token parse ---
|
|
69
|
+
t "parse E545" "$(naming_token_parse E545)" "545"
|
|
70
|
+
t "parse E545.1" "$(naming_token_parse E545.1)" "545 1"
|
|
71
|
+
t "parse [e12.3]" "$(naming_token_parse '[e12.3]')" "12 3"
|
|
72
|
+
naming_token_parse 545 >/dev/null; t "a bare number is not a token" "$?" "1"
|
|
73
|
+
naming_token_parse E545.x >/dev/null; t "E545.x is not a token" "$?" "1"
|
|
74
|
+
|
|
75
|
+
# --- token read from a title ---
|
|
76
|
+
t "token of a new effort" "$(naming_title_token '[E545] name')" "E545"
|
|
77
|
+
t "token of a new sub" "$(naming_title_token '[E545.3] name')" "E545.3"
|
|
78
|
+
t "token of a legacy effort" "$(naming_title_token '[Effort] 545 · [Core] name')" "E545"
|
|
79
|
+
t "token of a legacy sub" "$(naming_title_token '[Effort 545] 3 · name')" "E545.3"
|
|
80
|
+
naming_title_token 'plain issue' >/dev/null; t "a plain title has no token" "$?" "1"
|
|
81
|
+
t "parent of a new sub" "$(naming_title_parent '[E318.3] resolve profiles')" "318"
|
|
82
|
+
t "parent of a legacy sub" "$(naming_title_parent '[Effort 318] 3 · resolve')" "318"
|
|
83
|
+
naming_title_parent '[E318] umbrella' >/dev/null; t "an effort title has no parent" "$?" "1"
|
|
84
|
+
|
|
85
|
+
# --- prefix strip, new and legacy ---
|
|
86
|
+
t "strip new effort" "$(naming_strip_prefix '[E545] Every verb answers')" "Every verb answers"
|
|
87
|
+
t "strip new sub" "$(naming_strip_prefix '[E545.1] One naming convention')" "One naming convention"
|
|
88
|
+
t "strip new + flow tag" "$(naming_strip_prefix '[E545] [Core] tagged name')" "tagged name"
|
|
89
|
+
t "strip legacy effort" "$(naming_strip_prefix '[Effort] 86 · [Core] Plan future work')" "Plan future work"
|
|
90
|
+
t "strip legacy sub" "$(naming_strip_prefix '[Effort 182] 1 · Enforce it')" "Enforce it"
|
|
91
|
+
t "strip the placeholder" "$(naming_strip_prefix '[Effort] · demo effort')" "demo effort"
|
|
92
|
+
t "a plain title is kept" "$(naming_strip_prefix 'plain issue title')" "plain issue title"
|
|
93
|
+
|
|
94
|
+
# --- the wrappers in effort.sh keep legacy titles valid ---
|
|
95
|
+
(
|
|
96
|
+
# shellcheck source=/dev/null
|
|
97
|
+
. "$LIB/effort.sh" >/dev/null 2>&1
|
|
98
|
+
r=0
|
|
99
|
+
effort_title_lint "[Effort] 12 · [UI] operator navigation" 2>/dev/null || { echo "FAIL legacy parent via effort_title_lint"; r=1; }
|
|
100
|
+
effort_title_lint "[Effort 12] 4 · module tables" 2>/dev/null || { echo "FAIL legacy sub via effort_title_lint"; r=1; }
|
|
101
|
+
effort_title_lint "[E12] operator navigation" 2>/dev/null || { echo "FAIL new parent via effort_title_lint"; r=1; }
|
|
102
|
+
effort_title_lint "[E12.4] module tables" 2>/dev/null || { echo "FAIL new sub via effort_title_lint"; r=1; }
|
|
103
|
+
effort_title_lint "[E12] refactor the wiring" 2>/dev/null && { echo "FAIL jargon passed effort_title_lint"; r=1; }
|
|
104
|
+
effort_pr_title_check "feat(core): x [E546]" 546 2>/dev/null || { echo "FAIL check refuses [E546]"; r=1; }
|
|
105
|
+
effort_pr_title_check "feat(core): x [#546]" 546 2>/dev/null || { echo "FAIL check refuses [#546]"; r=1; }
|
|
106
|
+
effort_pr_title_check "feat(core): x [E5]" 546 2>/dev/null && { echo "FAIL check accepts the wrong effort"; r=1; }
|
|
107
|
+
effort_pr_title_check "feat(core): x [E5]" 2>/dev/null || { echo "FAIL check without a number refuses [E5]"; r=1; }
|
|
108
|
+
[ "$r" = 0 ] && echo "ok effort_title_lint + effort_pr_title_check accept both forms"
|
|
109
|
+
exit "$r"
|
|
110
|
+
) || fail=1
|
|
111
|
+
|
|
112
|
+
exit "$fail"
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# naming-verbs-test.sh — the naming rule at the verbs (E546.1), over the forge shim: each creating
|
|
4
|
+
# verb refuses a bad title before any forge write; `effort sub` titles [E<n>.<step>]; `effort retitle`
|
|
5
|
+
# is a dry run until --apply; `start E<n>.<step>` resolves the token. Hermetic, no network.
|
|
6
|
+
# Run: bash scripts/lib/naming-verbs-test.sh
|
|
7
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
8
|
+
set -u
|
|
9
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
10
|
+
# shellcheck source=/dev/null
|
|
11
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
12
|
+
LIB="$ROOT/scripts/lib"
|
|
13
|
+
fail=0
|
|
14
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
15
|
+
tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
16
|
+
command -v jq >/dev/null 2>&1 || { echo "naming-verbs-test: jq required" >&2; exit 1; }
|
|
17
|
+
|
|
18
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
19
|
+
export GH_LOG="$tmp/gh.log" GH_N="$tmp/n"; : > "$GH_LOG"; echo 49 > "$GH_N"
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$tmp/bin"
|
|
22
|
+
export PATH="$tmp/bin:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
|
|
23
|
+
export KIT_REPO="o/r" EFFORT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
|
|
24
|
+
unset KIT_CONFIG CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT GH_FAIL_EP KIT_PR_TITLE_STYLE
|
|
25
|
+
# Effort 30 has two subs: #301 a legacy title, #302 already new. Effort 40 has two untitled-by-step subs.
|
|
26
|
+
export GH_FIXTURE="$tmp/fixture.sh"
|
|
27
|
+
cat > "$GH_FIXTURE" <<'SH'
|
|
28
|
+
case "$method $ep" in
|
|
29
|
+
"GET repos/o/r/issues/30/sub_issues") out='[{"number":301,"state":"open","title":"[Effort 30] 1 · first step"},{"number":302,"state":"open","title":"[E30.2] second step"}]' ;;
|
|
30
|
+
"GET repos/o/r/issues/40/sub_issues") out='[{"number":401,"state":"open","title":"plain one"},{"number":402,"state":"open","title":"plain two"}]' ;;
|
|
31
|
+
esac
|
|
32
|
+
SH
|
|
33
|
+
writes() { grep -cE '^(POST|PATCH|PUT|DELETE) ' "$GH_LOG" | tr -d ' '; }
|
|
34
|
+
fresh() { : > "$GH_LOG"; echo 49 > "$GH_N"; }
|
|
35
|
+
|
|
36
|
+
# shellcheck source=/dev/null
|
|
37
|
+
source "$LIB/effort.sh" 2>/dev/null
|
|
38
|
+
# shellcheck source=/dev/null
|
|
39
|
+
source "$LIB/effort-ops.sh"
|
|
40
|
+
|
|
41
|
+
# ── effort new: a bad parent or sub name is refused before any write ─────────────────────────────
|
|
42
|
+
fresh
|
|
43
|
+
effort_new "refactor the wiring" "first sub" >/dev/null 2>"$tmp/err"; rc=$?
|
|
44
|
+
t "effort new: a jargon name is refused (rc 1)" "$rc" "1"
|
|
45
|
+
t "effort new: a refused name writes nothing" "$(writes)" "0"
|
|
46
|
+
tc "$tmp/err" "jargon word 'refactor'" "effort new: the reason is on stderr"
|
|
47
|
+
fresh
|
|
48
|
+
effort_new "demo effort" "a sub (with parens)" >/dev/null 2>"$tmp/err"; rc=$?
|
|
49
|
+
t "effort new: a bad sub name is refused (rc 1)" "$rc" "1"
|
|
50
|
+
t "effort new: a refused sub writes nothing" "$(writes)" "0"
|
|
51
|
+
|
|
52
|
+
# ── effort sub ────────────────────────────────────────────────────────────────────────────────────
|
|
53
|
+
export GH_TITLE="[E30] demo effort" GH_LABELS='[{"name":"effort"},{"name":"role:backend"},{"name":"kind:task"},{"name":"priority:p2"}]'
|
|
54
|
+
fresh
|
|
55
|
+
child="$(effort_sub 30 "third step" 2>"$tmp/err")"; rc=$?
|
|
56
|
+
t "effort sub: rc 0" "$rc" "0"
|
|
57
|
+
t "effort sub: echoes the child number" "$child" "50"
|
|
58
|
+
tc "$GH_LOG" '^POST repos/o/r/issues \{"title":"\[E30\.3\] third step"' "effort sub: titles [E<n>.<count+1>] <name>"
|
|
59
|
+
tc "$GH_LOG" '^POST repos/o/r/issues .*"labels":\["kind:task","priority:p2","role:backend"\]' "effort sub: inherits kind, priority and role"
|
|
60
|
+
tc "$GH_LOG" '^POST repos/o/r/issues/30/sub_issues ' "effort sub: links the child as a native sub-issue"
|
|
61
|
+
fresh
|
|
62
|
+
effort_sub 30 "one two three four five six seven" >/dev/null 2>"$tmp/err"; rc=$?
|
|
63
|
+
t "effort sub: a long name is refused (rc 1)" "$rc" "1"
|
|
64
|
+
t "effort sub: a refused name writes nothing" "$(writes)" "0"
|
|
65
|
+
export GH_LABELS='[{"name":"kind:task"}]'
|
|
66
|
+
fresh
|
|
67
|
+
effort_sub 30 "third step" >/dev/null 2>"$tmp/err"; rc=$?
|
|
68
|
+
t "effort sub: a non-effort parent is refused" "$rc" "1"
|
|
69
|
+
t "effort sub: nothing written for a non-effort" "$(writes)" "0"
|
|
70
|
+
|
|
71
|
+
# ── effort retitle ────────────────────────────────────────────────────────────────────────────────
|
|
72
|
+
export GH_TITLE="[Effort] 30 · [Core] demo effort"
|
|
73
|
+
fresh
|
|
74
|
+
out="$(effort_retitle 30 2>&1)"; rc=$?
|
|
75
|
+
t "retitle dry run: rc 0" "$rc" "0"
|
|
76
|
+
t "retitle dry run: writes nothing" "$(writes)" "0"
|
|
77
|
+
case "$out" in *"-> [E30] demo effort"*"-> [E30.1] first step"*"dry run: 2 title(s)"*) echo "ok: retitle dry run lists the parent and the legacy sub" ;;
|
|
78
|
+
*) echo "FAIL: retitle dry run output: $out"; fail=1 ;; esac
|
|
79
|
+
case "$out" in *"#302"*) echo "FAIL: retitle lists a title already in the new form"; fail=1 ;; *) echo "ok: retitle skips a title already in the new form" ;; esac
|
|
80
|
+
fresh
|
|
81
|
+
effort_retitle 30 --apply >/dev/null 2>&1; rc=$?
|
|
82
|
+
t "retitle --apply: rc 0" "$rc" "0"
|
|
83
|
+
tc "$GH_LOG" '^PATCH repos/o/r/issues/30 \{"title":"\[E30\] demo effort"\}$' "retitle --apply renames the parent"
|
|
84
|
+
tc "$GH_LOG" '^PATCH repos/o/r/issues/301 \{"title":"\[E30\.1\] first step"\}$' "retitle --apply renames the legacy sub"
|
|
85
|
+
t "retitle --apply: two writes" "$(writes)" "2"
|
|
86
|
+
|
|
87
|
+
# ── start: the token resolves ─────────────────────────────────────────────────────────────────────
|
|
88
|
+
(
|
|
89
|
+
# shellcheck source=/dev/null
|
|
90
|
+
. "$LIB/worktree-start.sh" >/dev/null 2>&1
|
|
91
|
+
export WT_START_REPO="o/r"
|
|
92
|
+
r=0
|
|
93
|
+
[ "$(_wt_resolve_token E545 2>/dev/null)" = 545 ] || { echo "FAIL: E545 -> 545"; r=1; }
|
|
94
|
+
[ "$(_wt_resolve_token E30.2 2>/dev/null)" = 302 ] || { echo "FAIL: E30.2 by title -> 302"; r=1; }
|
|
95
|
+
[ "$(_wt_resolve_token E30.1 2>/dev/null)" = 301 ] || { echo "FAIL: E30.1 by legacy title -> 301"; r=1; }
|
|
96
|
+
[ "$(_wt_resolve_token E40.2 2>/dev/null)" = 402 ] || { echo "FAIL: E40.2 by position -> 402"; r=1; }
|
|
97
|
+
_wt_resolve_token E40.5 >/dev/null 2>&1 && { echo "FAIL: E40.5 should not resolve"; r=1; }
|
|
98
|
+
_wt_resolve_token E4x >/dev/null 2>&1 && { echo "FAIL: E4x is not a token"; r=1; }
|
|
99
|
+
[ "$r" = 0 ] && echo "ok: start resolves E<n>, E<n>.<step> by title, legacy title and position"
|
|
100
|
+
exit "$r"
|
|
101
|
+
) || fail=1
|
|
102
|
+
|
|
103
|
+
# ── cckit new: a bad standalone title is refused before any write ─────────────────────────────────
|
|
104
|
+
(
|
|
105
|
+
cd "$tmp" || exit 1
|
|
106
|
+
# shellcheck source=/dev/null
|
|
107
|
+
. "$LIB/kit-task-ops.sh"
|
|
108
|
+
r=0
|
|
109
|
+
fresh
|
|
110
|
+
kto_task_new "[E12] an effort title" backend task p2 "" "" "" x >/dev/null 2>&1 && { echo "FAIL: new accepted a prefixed title"; r=1; }
|
|
111
|
+
[ "$(writes)" = 0 ] || { echo "FAIL: new wrote to the forge on a bad title"; r=1; }
|
|
112
|
+
fresh
|
|
113
|
+
kto_task_new "one two three four five six seven" backend task p2 "" "" "" x >/dev/null 2>&1 && { echo "FAIL: new accepted 7 words"; r=1; }
|
|
114
|
+
[ "$(writes)" = 0 ] || { echo "FAIL: new wrote on a long title"; r=1; }
|
|
115
|
+
[ "$r" = 0 ] && echo "ok: cckit new refuses a bad title and writes nothing"
|
|
116
|
+
# The PR title carries the trailing token.
|
|
117
|
+
[ "$(kto_pr_title "[E30.2] second step" "fix the thing" "kind:fix" 302)" = "fix: second step [E30.2]" ] \
|
|
118
|
+
|| { echo "FAIL: kto_pr_title sub token: $(kto_pr_title "[E30.2] second step" "fix the thing" "kind:fix" 302)"; r=1; }
|
|
119
|
+
[ "$(kto_pr_title "Fix the thing" "fix the thing" "kind:fix" 42)" = "fix: Fix the thing [#42]" ] \
|
|
120
|
+
|| { echo "FAIL: kto_pr_title standalone token: $(kto_pr_title "Fix the thing" "fix the thing" "kind:fix" 42)"; r=1; }
|
|
121
|
+
[ "$r" = 0 ] && echo "ok: cckit pr titles end in the work's token"
|
|
122
|
+
exit "$r"
|
|
123
|
+
) || fail=1
|
|
124
|
+
|
|
125
|
+
[ "$fail" -eq 0 ] && echo "ALL OK"
|
|
126
|
+
exit "$fail"
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# naming.sh — the ONE title convention (rules/naming-and-ids.md, E546.1). Every verb that creates or
|
|
4
|
+
# titles an issue or a pull request calls naming_title_lint before it writes to the forge, and every
|
|
5
|
+
# verb that reads a title back strips its prefix here, so the generator, the validator and the rule
|
|
6
|
+
# say the same thing.
|
|
7
|
+
#
|
|
8
|
+
# effort [E<n>] <name> e.g. [E545] Every verb answers a question
|
|
9
|
+
# sub [E<n>.<step>] <name> step = the sub's 1-based position in the effort
|
|
10
|
+
# issue <name> a standalone issue: plain outcome, no prefix
|
|
11
|
+
# pr type(scope): subject [E<n>] effort · [E<n>.<step>] sub · [#<n>] standalone
|
|
12
|
+
#
|
|
13
|
+
# The legacy forms `[Effort] N · <name>` and `[Effort N] M · <name>`, with an optional `[Flow] ` tag
|
|
14
|
+
# after the prefix, still parse and still lint, so issues opened before the change stay valid until
|
|
15
|
+
# `cckit effort retitle --apply` renames them. The flow lives in the `flow:` label; no generator
|
|
16
|
+
# writes a `[Flow]` tag any more.
|
|
17
|
+
#
|
|
18
|
+
# Functions:
|
|
19
|
+
# naming_title_lint <effort|sub|issue|pr> <title> rc 0 clean · 1 + reasons on stderr · 2 usage
|
|
20
|
+
# naming_effort_title <n> <name> echo "[E<n>] <name>"
|
|
21
|
+
# naming_sub_title <n> <step> <name> echo "[E<n>.<step>] <name>"
|
|
22
|
+
# naming_strip_prefix <title> echo the name: new or legacy prefix + [Flow] peeled
|
|
23
|
+
# naming_strip_structural <title> the same, with a [Flow] tag kept
|
|
24
|
+
# naming_title_token <title> echo E<n> / E<n>.<step> read from the prefix, or rc 1
|
|
25
|
+
# naming_title_parent <title> echo <n> when the title is a sub of effort n, or rc 1
|
|
26
|
+
# naming_token_parse <token> E545 -> "545" · E545.1 -> "545 1" · else rc 1
|
|
27
|
+
#
|
|
28
|
+
# bash 3.2 compatible; sourceable under zsh (no BASH_REMATCH, no arrays in the pure helpers).
|
|
29
|
+
# errors: strict — a validator: rc 1 on a title that breaks the rule
|
|
30
|
+
|
|
31
|
+
if ! command -v commitlint_check >/dev/null 2>&1; then
|
|
32
|
+
if [ -n "${BASH_SOURCE:-}" ]; then _nm_dir="${BASH_SOURCE[0]}"
|
|
33
|
+
elif [ -n "${ZSH_VERSION:-}" ]; then eval '_nm_dir="${(%):-%x}"'
|
|
34
|
+
else _nm_dir="$0"; fi
|
|
35
|
+
_nm_dir="$(cd "$(dirname "$_nm_dir")" 2>/dev/null && pwd)"
|
|
36
|
+
# shellcheck source=/dev/null
|
|
37
|
+
[ -n "$_nm_dir" ] && [ -f "$_nm_dir/commitlint.sh" ] && . "$_nm_dir/commitlint.sh"
|
|
38
|
+
unset _nm_dir
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# The PR token: the work a PR carries, trailing, in square brackets. `[share-<digits>]` is the one
|
|
42
|
+
# documented exception, the title `cckit task share` writes (no issue exists for a share).
|
|
43
|
+
NAMING_PR_TOKEN_RE='\[(E[0-9]+(\.[0-9]+)?|#[0-9]+|share-[0-9]+)\][[:space:]]*$'
|
|
44
|
+
|
|
45
|
+
naming_effort_title() { printf '[E%s] %s' "${1#\#}" "${2:-}"; }
|
|
46
|
+
naming_sub_title() { printf '[E%s.%s] %s' "${1#\#}" "${2:-}" "${3:-}"; }
|
|
47
|
+
|
|
48
|
+
# naming_token_parse <token> — "E545" -> "545", "E545.1" -> "545 1"; brackets and a lowercase e are
|
|
49
|
+
# accepted. rc 1 for anything else.
|
|
50
|
+
naming_token_parse() {
|
|
51
|
+
local t="${1:-}" out
|
|
52
|
+
t="${t#\[}"; t="${t%\]}"
|
|
53
|
+
out="$(printf '%s' "$t" | sed -nE -e 's/^[Ee]([0-9]+)\.([0-9]+)$/\1 \2/p' -e 's/^[Ee]([0-9]+)$/\1/p')"
|
|
54
|
+
[ -n "$out" ] || return 1
|
|
55
|
+
printf '%s\n' "$out"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# naming_title_token <title> — the token a title's prefix names: [E545.1] and [Effort 545] 1 · give
|
|
59
|
+
# E545.1; [E545] and [Effort] 545 · give E545. rc 1 for a title with neither prefix.
|
|
60
|
+
naming_title_token() {
|
|
61
|
+
local out
|
|
62
|
+
out="$(printf '%s' "${1:-}" | sed -nE \
|
|
63
|
+
-e 's/^\[E([0-9]+)\.([0-9]+)\] .*/E\1.\2/p' \
|
|
64
|
+
-e 's/^\[E([0-9]+)\] .*/E\1/p' \
|
|
65
|
+
-e 's/^\[Effort ([0-9]+)\] ([0-9]+) ·.*/E\1.\2/p' \
|
|
66
|
+
-e 's/^\[Effort\] ([0-9]+) ·.*/E\1/p' | sed -n 1p)"
|
|
67
|
+
[ -n "$out" ] || return 1
|
|
68
|
+
printf '%s\n' "$out"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# naming_title_parent <title> — the effort number of a SUB title, new or legacy. rc 1 otherwise.
|
|
72
|
+
naming_title_parent() {
|
|
73
|
+
local tok; tok="$(naming_title_token "${1:-}")" || return 1
|
|
74
|
+
case "$tok" in *.*) tok="${tok%%.*}"; printf '%s\n' "${tok#E}" ;; *) return 1 ;; esac
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# naming_strip_structural <title> — peel only the structural prefix, new or legacy (including the
|
|
78
|
+
# number-less `[Effort] · ` placeholder); a `[Flow] ` tag after it is kept.
|
|
79
|
+
naming_strip_structural() {
|
|
80
|
+
printf '%s' "${1:-}" | sed -E \
|
|
81
|
+
-e 's/^\[E[0-9]+(\.[0-9]+)?\] +//' \
|
|
82
|
+
-e 's/^\[Effort( [0-9]+)?\] ([0-9]+ )?· ?//'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# naming_strip_prefix <title> — the human name: the structural prefix and then one leading `[Flow] `
|
|
86
|
+
# tag are peeled.
|
|
87
|
+
naming_strip_prefix() {
|
|
88
|
+
naming_strip_structural "${1:-}" | sed -E 's/^\[[A-Za-z]+\] +//'
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# _naming_name_reasons <name> — the name rules, one failed rule per line on stdout (none = clean).
|
|
92
|
+
# The body of the former effort_title_lint: a short plain-language outcome, ≤ 6 words, no
|
|
93
|
+
# parentheses, sub-clauses, glyphs, code identifiers or words from the jargon list.
|
|
94
|
+
_naming_name_reasons() {
|
|
95
|
+
local name="$1" w wc
|
|
96
|
+
local jargon="${EFFORT_TITLE_JARGON:-chrome seam contract claim rescue stash teardown scaffolding shim boilerplate refactor wiring}"
|
|
97
|
+
[ -n "$(printf '%s' "$name" | tr -d '[:space:]')" ] || { echo "the name is empty — say the outcome"; return 0; }
|
|
98
|
+
case "$name" in *"("*|*")"*) echo "no parentheses — detail goes in the body" ;; esac
|
|
99
|
+
case "$name" in *" — "*|*" · "*|*" / "*) echo "no ' — ' / ' · ' / ' / ' sub-clauses — one clear phrase" ;; esac
|
|
100
|
+
case "$name" in *—*|*▾*|*▸*|*→*|*✓*|*✗*|*…*|*•*) echo "no glyphs (— ▾ ▸ → ✓ ✗ … •) in the title" ;; esac
|
|
101
|
+
if grep -qE '\.(sh|ts|tsx|js|mjs|json|css|md|ya?ml)([^A-Za-z0-9]|$)|[a-z0-9]+_[a-z0-9]+|(^|[^A-Za-z])(scripts|apps|packages|src)/' <<<"$name"; then
|
|
102
|
+
echo "no code identifiers (file names, paths, snake_case) — name the outcome"
|
|
103
|
+
fi
|
|
104
|
+
# One word per line, read back: zsh does not word-split an unquoted expansion.
|
|
105
|
+
printf '%s\n' "$jargon" | tr ' ' '\n' | while IFS= read -r w; do
|
|
106
|
+
[ -n "$w" ] || continue
|
|
107
|
+
grep -qiwE "$w" <<<"$name" && echo "jargon word '$w' — use plain language"
|
|
108
|
+
done
|
|
109
|
+
wc=$(printf '%s\n' "$name" | wc -w | tr -d ' ')
|
|
110
|
+
[ "$wc" -gt 6 ] && echo "name is $wc words — keep it ≤ 6 (detail goes in the body)"
|
|
111
|
+
return 0
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# naming_title_lint <effort|sub|issue|pr> <title> — rc 0 when <title> follows the rule for <kind>;
|
|
115
|
+
# rc 1 with every failed rule on stderr; rc 2 on a usage error.
|
|
116
|
+
naming_title_lint() {
|
|
117
|
+
local kind="${1:-}" title="${2:-}" name="" reasons="" flow flows
|
|
118
|
+
[ -n "$title" ] || { echo "naming_title_lint: a title is required" >&2; return 2; }
|
|
119
|
+
case "$kind" in
|
|
120
|
+
effort)
|
|
121
|
+
name="$(printf '%s' "$title" | sed -E -e 's/^\[E[0-9]+\] +//' -e 's/^\[Effort\] [0-9]+ · ?//')"
|
|
122
|
+
[ "$name" = "$title" ] && reasons="missing the '[E<n>] ' prefix" ;;
|
|
123
|
+
sub)
|
|
124
|
+
name="$(printf '%s' "$title" | sed -E -e 's/^\[E[0-9]+\.[0-9]+\] +//' -e 's/^\[Effort [0-9]+\] [0-9]+ · ?//')"
|
|
125
|
+
[ "$name" = "$title" ] && reasons="missing the '[E<n>.<step>] ' prefix" ;;
|
|
126
|
+
issue)
|
|
127
|
+
name="$title"
|
|
128
|
+
case "$title" in "["*) reasons="no prefix — a standalone issue title is a plain outcome (an effort is '[E<n>] <name>')" ;; esac ;;
|
|
129
|
+
pr)
|
|
130
|
+
# pr.titleStyle = issue-title: the PR title IS the issue title, and the repo runs no
|
|
131
|
+
# Conventional Commit gate, so only an empty title is refused here.
|
|
132
|
+
[ "${KIT_PR_TITLE_STYLE:-conventional}" = "issue-title" ] && return 0
|
|
133
|
+
if command -v commitlint_check >/dev/null 2>&1; then
|
|
134
|
+
commitlint_check "$title" >/dev/null 2>&1 || reasons="not a Conventional Commit subject — type(scope): subject"
|
|
135
|
+
else
|
|
136
|
+
grep -qE '^[a-z]+(\([a-z0-9][a-z0-9._/-]*\))?!?: [^[:space:]]' <<<"$title" \
|
|
137
|
+
|| reasons="not a Conventional Commit subject — type(scope): subject"
|
|
138
|
+
fi
|
|
139
|
+
if ! grep -qE "$NAMING_PR_TOKEN_RE" <<<"$title"; then
|
|
140
|
+
reasons="${reasons:+$reasons
|
|
141
|
+
}no trailing token — end with [E<n>] (effort), [E<n>.<step>] (sub) or [#<n>] (standalone issue)"
|
|
142
|
+
fi ;;
|
|
143
|
+
*) echo "naming_title_lint: kind must be effort, sub, issue or pr (got '$kind')" >&2; return 2 ;;
|
|
144
|
+
esac
|
|
145
|
+
|
|
146
|
+
if [ "$kind" != pr ]; then
|
|
147
|
+
# One optional [Flow] tag is tolerated after an effort or sub prefix (legacy titles carry one);
|
|
148
|
+
# it must come from the flow vocabulary.
|
|
149
|
+
if [ "$kind" != issue ]; then
|
|
150
|
+
flow="$(printf '%s' "$name" | sed -nE 's/^\[([A-Za-z]+)\] +.*/\1/p')"
|
|
151
|
+
if [ -n "$flow" ]; then
|
|
152
|
+
name="$(printf '%s' "$name" | sed -E 's/^\[[A-Za-z]+\] +//')"
|
|
153
|
+
flows="${EFFORT_FLOWS:-Core UI API Docs Infra Auth Data Web App}"
|
|
154
|
+
case " $flows " in
|
|
155
|
+
*" $flow "*) : ;;
|
|
156
|
+
*) reasons="${reasons:+$reasons
|
|
157
|
+
}flow tag [$flow] is not in the vocabulary ($flows)" ;;
|
|
158
|
+
esac
|
|
159
|
+
fi
|
|
160
|
+
fi
|
|
161
|
+
local more; more="$(_naming_name_reasons "$name")"
|
|
162
|
+
[ -n "$more" ] && reasons="${reasons:+$reasons
|
|
163
|
+
}$more"
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
[ -n "$reasons" ] || return 0
|
|
167
|
+
{
|
|
168
|
+
echo "✗ $kind title breaks the naming rule (rules/naming-and-ids.md): $title"
|
|
169
|
+
printf '%s\n' "$reasons" | sed 's/^/ - /'
|
|
170
|
+
} >&2
|
|
171
|
+
return 1
|
|
172
|
+
}
|