@jeiemgi/cckit 0.8.0 → 0.9.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/README.md +14 -0
- package/bin/cckit +8 -4
- package/cckit.config.json +1 -1
- package/package.json +1 -1
- package/scripts/guard-raw-git-ops-test.sh +8 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +12 -0
- package/scripts/lib/effort-ops.sh +88 -11
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +11 -1
- package/scripts/lib/gh-project.sh +14 -0
- package/scripts/lib/gh-rest-test.sh +301 -0
- package/scripts/lib/gh-rest.sh +289 -0
- package/scripts/lib/kit-gc.sh +21 -3
- package/scripts/lib/kit-task-ops.sh +190 -61
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +63 -6
- package/scripts/lib/test-env-test.sh +3 -3
- package/scripts/lib/test-env.sh +7 -4
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-start.sh +16 -1
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +19 -6
package/scripts/lib/test-env.sh
CHANGED
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
#
|
|
5
5
|
# A developer shell that has run `load_kit_config` (or set KIT_CONFIG by hand) exports KIT_*,
|
|
6
6
|
# CCKIT_* and EFFORT_* variables. A test that inherits them reads the developer's project instead
|
|
7
|
-
# of its own fixture: KIT_CONFIG=/elsewhere made five suites fail.
|
|
8
|
-
#
|
|
7
|
+
# of its own fixture: KIT_CONFIG=/elsewhere made five suites fail. CLAUDE_CODE_REMOTE is sealed too:
|
|
8
|
+
# in a cloud session it switches the GitHub transport to REST (#396), and the suites that stub the
|
|
9
|
+
# gh subcommands expect the default. Source this first, then call test_env_seal before the test sets
|
|
10
|
+
# its own variables.
|
|
9
11
|
#
|
|
10
|
-
# test_env_seal unset every exported KIT_* / CCKIT_* / EFFORT_* variable
|
|
12
|
+
# test_env_seal unset every exported KIT_* / CCKIT_* / EFFORT_* variable (and
|
|
13
|
+
# CLAUDE_CODE_REMOTE) in this shell
|
|
11
14
|
# test_env_unset_args print `-u NAME` pairs for env(1), one per line (the runner uses these)
|
|
12
15
|
#
|
|
13
16
|
# scripts/test.sh scrubs the same set before it runs each test; this covers a test run directly.
|
|
@@ -15,7 +18,7 @@
|
|
|
15
18
|
# bash 3.2 + zsh compatible.
|
|
16
19
|
|
|
17
20
|
_test_env_names() {
|
|
18
|
-
env | sed -n 's/^\(KIT_[A-Za-z0-9_]*\)=.*/\1/p; s/^\(CCKIT_[A-Za-z0-9_]*\)=.*/\1/p; s/^\(EFFORT_[A-Za-z0-9_]*\)=.*/\1/p'
|
|
21
|
+
env | sed -n 's/^\(KIT_[A-Za-z0-9_]*\)=.*/\1/p; s/^\(CCKIT_[A-Za-z0-9_]*\)=.*/\1/p; s/^\(EFFORT_[A-Za-z0-9_]*\)=.*/\1/p; s/^\(CLAUDE_CODE_REMOTE\)=.*/\1/p'
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
test_env_seal() {
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
# Self-test: bash scripts/lib/worktree-issue-test.sh (runs the cases under bash + zsh)
|
|
15
15
|
# errors: mixed — name parsing is pure; the issue-open check needs gh
|
|
16
16
|
|
|
17
|
+
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
18
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
19
|
+
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
[ -f "$_ghr_lib" ] && . "$_ghr_lib"
|
|
22
|
+
unset _ghr_lib
|
|
23
|
+
fi
|
|
24
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
25
|
+
|
|
17
26
|
# Echo the issue number a branch name / worktree path belongs to (empty if none, e.g. bot branches).
|
|
18
27
|
# Normalize the numeric segment of a branch/dir name to an issue number.
|
|
19
28
|
# Accepts "1602" and also the effort SUB form "1604a" — `sub/<N><letter>-<slug>` is the documented
|
|
@@ -70,6 +79,11 @@ wt_issue_state() {
|
|
|
70
79
|
local n="$1" repo="${2:-}"
|
|
71
80
|
[[ -z "$n" ]] && return 0
|
|
72
81
|
command -v gh >/dev/null 2>&1 || return 0
|
|
82
|
+
if cckit_gh_rest; then
|
|
83
|
+
repo="${repo:-${KIT_REPO:-}}"; [[ -n "$repo" ]] || return 0
|
|
84
|
+
gh api "repos/$repo/issues/$n" --jq .state 2>/dev/null | tr '[:upper:]' '[:lower:]'
|
|
85
|
+
return 0
|
|
86
|
+
fi
|
|
73
87
|
local args=(issue view "$n" --json state --jq .state)
|
|
74
88
|
[[ -n "$repo" ]] && args+=(--repo "$repo")
|
|
75
89
|
gh "${args[@]}" 2>/dev/null | tr '[:upper:]' '[:lower:]'
|
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
# Requires: gh, jq, git, scripts/lib/gh-project.sh (board update). bash 3.2 compatible.
|
|
13
13
|
# errors: strict — rc 1 on failure; a half-made worktree is never reported as ready
|
|
14
14
|
|
|
15
|
+
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
16
|
+
if ! command -v cckit_gh_rest >/dev/null 2>&1; then
|
|
17
|
+
_ghr_lib="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)/gh-rest.sh"
|
|
18
|
+
# shellcheck source=/dev/null
|
|
19
|
+
[ -f "$_ghr_lib" ] && . "$_ghr_lib"
|
|
20
|
+
unset _ghr_lib
|
|
21
|
+
fi
|
|
22
|
+
command -v cckit_gh_rest >/dev/null 2>&1 || cckit_gh_rest() { return 1; }
|
|
23
|
+
|
|
15
24
|
WT_START_REPO="${WT_START_REPO:-${KIT_REPO:-}}"
|
|
16
25
|
|
|
17
26
|
# _wt_set_port <app-env-file> <port> <issue-num> — append a per-worktree dev PORT to an app's
|
|
@@ -523,8 +532,12 @@ wt_start() {
|
|
|
523
532
|
# The board's Status is set server-side by built-in automations (Item closed→Done, PR
|
|
524
533
|
# merged→Done) — wt_start no longer writes In Progress, so no board helpers are loaded here.
|
|
525
534
|
|
|
535
|
+
if cckit_gh_rest; then
|
|
536
|
+
meta="$(gh_rest_issue_json "$WT_START_REPO" "$num" 2>/dev/null)" || { echo "[#$num] issue not found" >&2; return 1; }
|
|
537
|
+
else
|
|
526
538
|
meta="$(gh issue view "$num" --repo "$WT_START_REPO" --json title,labels 2>/dev/null)" \
|
|
527
539
|
|| { echo "[#$num] issue not found" >&2; return 1; }
|
|
540
|
+
fi
|
|
528
541
|
title="$(echo "$meta" | jq -r '.title')"
|
|
529
542
|
kind="$(echo "$meta" | jq -r '([.labels[].name | select(startswith("kind:"))][0] // "kind:task") | sub("^kind:";"")')"
|
|
530
543
|
if [[ -n "$slug_override" ]]; then
|
|
@@ -578,7 +591,9 @@ wt_start() {
|
|
|
578
591
|
# transitions server-side (Item added→Todo, PR linked→In Review, closed/merged→Done) — but GitHub
|
|
579
592
|
# has no "branch started" trigger, so the kit owns In Progress. Cheap now: an O(1) issue.projectItems
|
|
580
593
|
# lookup on the org board, not a full-board scan. Best-effort — a board hiccup never fails the start.
|
|
581
|
-
if
|
|
594
|
+
if cckit_gh_rest; then
|
|
595
|
+
command -v cckit_board_skipped >/dev/null 2>&1 && cckit_board_skipped
|
|
596
|
+
elif source "$root/scripts/lib/gh-project.sh" 2>/dev/null; then
|
|
582
597
|
[[ -n "${STATUS_FIELD_ID:-}" ]] || load_project_ids >/dev/null 2>&1 || true
|
|
583
598
|
# Claim precheck (#124): if the issue is ALREADY In Progress on the board, another session may
|
|
584
599
|
# already own it — warn (never block; the start still proceeds) so two agents don't collide.
|
|
@@ -52,6 +52,8 @@ _grg_segments() {
|
|
|
52
52
|
# _grg_classify <segment> — print the raw-op key for one simple command, or nothing.
|
|
53
53
|
_grg_classify() {
|
|
54
54
|
local s="$1"
|
|
55
|
+
# `--help` / `-h` only prints usage: read-only, never a bypass.
|
|
56
|
+
printf '%s' "$s" | grep -qE '[[:space:]](--help|-h)([[:space:]]|$)' && return 0
|
|
55
57
|
if printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+issue[[:space:]]+create([[:space:]]|$)'; then echo issue-create
|
|
56
58
|
elif printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+issue[[:space:]]+close([[:space:]]|$)'; then echo issue-close
|
|
57
59
|
elif printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+pr[[:space:]]+create([[:space:]]|$)'; then echo pr-create
|
|
@@ -61,12 +63,21 @@ _grg_classify() {
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
# _grg_hint <key> — the verb to run instead.
|
|
64
|
-
_grg_hint() {
|
|
66
|
+
_grg_hint() { # <key> [segment] — the segment's flags pick the matching verb flag (#376/#377)
|
|
67
|
+
local seg="${2:-}" n
|
|
65
68
|
case "$1" in
|
|
66
69
|
issue-create) echo 'cckit new --role <role> [--kind K --priority P --body-file F] "<title>" (multi-part work: cckit effort new)' ;;
|
|
67
|
-
issue-close)
|
|
70
|
+
issue-close)
|
|
71
|
+
n="$(printf '%s' "$seg" | sed -nE 's/.*--duplicate-of[= ]+#?([0-9]+).*/\1/p')"
|
|
72
|
+
if [ -n "$n" ]; then echo "cckit close <issue> --duplicate-of $n (state_reason duplicate, board Done)"
|
|
73
|
+
elif printf '%s' "$seg" | grep -qiE -- '(--reason|-r)[= ]+.?not[ _-]?planned'; then
|
|
74
|
+
echo 'cckit close <issue> "<why>" --reason not-planned (superseded: --superseded-by <N>)'
|
|
75
|
+
else echo 'cckit close <issue> "<summary>" [--reason completed|not-planned|duplicate] (an effort: cckit effort close <N>)'; fi ;;
|
|
68
76
|
pr-create) echo 'cckit pr <issue> "<summary>" (an effort: cckit effort pr <N> --summary-file F --for-agents-file F)' ;;
|
|
69
|
-
pr-merge)
|
|
77
|
+
pr-merge)
|
|
78
|
+
if printf '%s' "$seg" | grep -qE -- '(--merge|-m)([[:space:]]|$)'; then echo 'cckit merge [<pr>] --merge (a merge commit; also into an effort/<N> base)'
|
|
79
|
+
elif printf '%s' "$seg" | grep -qE -- '(--rebase|-r)([[:space:]]|$)'; then echo 'cckit merge [<pr>] --rebase'
|
|
80
|
+
else echo 'cckit merge [<pr>] [--merge|--rebase] (an effort: cckit effort close <N>)'; fi ;;
|
|
70
81
|
branch) echo 'cckit start <issue> (an effort: cckit effort start <N>)' ;;
|
|
71
82
|
esac
|
|
72
83
|
}
|
|
@@ -109,6 +120,8 @@ branch|git -C /tmp/r switch -c feat/1-x
|
|
|
109
120
|
branch|git worktree add ../wt -b feat/1-x
|
|
110
121
|
branch|git checkout -q -b feat/1-x origin/develop
|
|
111
122
|
|gh issue view 5
|
|
123
|
+
|gh issue close --help
|
|
124
|
+
|gh pr merge -h
|
|
112
125
|
|gh pr list --state open
|
|
113
126
|
|gh pr view 7 --json body
|
|
114
127
|
|git checkout develop
|
|
@@ -135,10 +148,10 @@ cmd="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)"
|
|
|
135
148
|
# Cheap prefilter: nothing to inspect unless gh or git appears at all.
|
|
136
149
|
printf '%s' "$cmd" | grep -qE '(^|[^A-Za-z0-9_-])(gh|git)[[:space:]]' || exit 0
|
|
137
150
|
|
|
138
|
-
key=""
|
|
151
|
+
key=""; hit=""
|
|
139
152
|
while IFS= read -r seg; do
|
|
140
153
|
[ -z "$seg" ] && continue
|
|
141
|
-
key="$(_grg_classify "$seg")"; [ -n "$key" ] && break
|
|
154
|
+
key="$(_grg_classify "$seg")"; [ -n "$key" ] && { hit="$seg"; break; }
|
|
142
155
|
done <<< "$(_grg_segments "$cmd")"
|
|
143
156
|
[ -z "$key" ] && exit 0
|
|
144
157
|
|
|
@@ -174,7 +187,7 @@ fi
|
|
|
174
187
|
|
|
175
188
|
{
|
|
176
189
|
echo "BLOCKED: raw '$key' in a cckit repo. The verb owns the side effects (board, labels, worktree); the raw command skips them silently."
|
|
177
|
-
echo "Run instead: $(_grg_hint "$key")"
|
|
190
|
+
echo "Run instead: $(_grg_hint "$key" "${hit:-}")"
|
|
178
191
|
echo "If the verb is broken, fix the verb. Deliberate one-off: prefix KIT_ALLOW_RAW=1 (recorded in <git-common-dir>/cckit/raw-bypass.log)."
|
|
179
192
|
} >&2
|
|
180
193
|
exit 2
|