@jeiemgi/cckit 0.2.0 → 0.3.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 +21 -8
- package/README.md +63 -5
- package/bin/cckit +37 -16
- package/cckit.config.json +1 -1
- package/commands/kit-doctor.md +3 -1
- package/kit.config.schema.json +24 -0
- package/package.json +1 -1
- package/scripts/annotate-setup.sh +7 -2
- package/scripts/capture-project-ids.sh +23 -10
- package/scripts/init.sh +22 -4
- package/scripts/kit-doctor.sh +185 -7
- package/scripts/kit-version-check-test.sh +36 -0
- package/scripts/kit-version-check.sh +19 -4
- package/scripts/knowledge-lint.sh +4 -1
- package/scripts/lib/board-view-test.sh +54 -0
- package/scripts/lib/board-view.sh +80 -0
- package/scripts/lib/captain-test.sh +18 -0
- package/scripts/lib/captain.sh +92 -5
- package/scripts/lib/config-path-test.sh +47 -0
- package/scripts/lib/config-path.sh +29 -0
- package/scripts/lib/copilot.sh +9 -9
- package/scripts/lib/effort-metrics-test.sh +57 -0
- package/scripts/lib/effort-metrics.sh +19 -5
- package/scripts/lib/effort-ops-test.sh +51 -2
- package/scripts/lib/effort-ops.sh +314 -49
- package/scripts/lib/effort-parity-test.sh +128 -0
- package/scripts/lib/effort-slug-test.sh +87 -0
- package/scripts/lib/effort-slug.sh +104 -0
- package/scripts/lib/effort.sh +34 -0
- package/scripts/lib/gh-project-test.sh +95 -0
- package/scripts/lib/gh-project.sh +22 -7
- package/scripts/lib/git-remote-test.sh +57 -0
- package/scripts/lib/git-remote.sh +21 -0
- package/scripts/lib/kit-config-test.sh +37 -0
- package/scripts/lib/kit-config.sh +33 -13
- package/scripts/lib/kit-events.sh +5 -3
- package/scripts/lib/kit-gc-test.sh +88 -0
- package/scripts/lib/kit-gc.sh +136 -19
- package/scripts/lib/kit-local.sh +8 -1
- package/scripts/lib/next.sh +3 -3
- package/scripts/lib/plan-next-test.sh +87 -0
- package/scripts/lib/plan-next.sh +212 -0
- package/scripts/lib/project-scan.sh +7 -1
- package/scripts/lib/worktree-start.sh +12 -3
- package/scripts/lib/zsh-safety-test.sh +73 -0
- package/scripts/portable-test.sh +62 -20
- package/scripts/setup-labels.sh +13 -2
- package/scripts/showcase.sh +13 -4
- package/scripts/status-test.sh +63 -0
- package/scripts/status.sh +12 -4
- package/scripts/task-sync.sh +79 -10
- package/skills/kit-autopilot/SKILL.md +5 -0
- package/skills/{docs-writer → kit-docs-writer}/SKILL.md +2 -2
- package/skills/kit-effort-new/SKILL.md +39 -111
- package/skills/kit-effort-pr/SKILL.md +6 -2
- package/skills/kit-next/SKILL.md +4 -0
- package/skills/kit-plan-next/SKILL.md +82 -0
- package/templates/hooks/mempal_session_start.sh.tmpl +36 -2
- package/templates/rules/effort-model.md +26 -6
- package/templates/rules/mempalace.md +1 -0
- package/templates/rules/plan-next.md +58 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# effort-slug-test.sh — covers the effort slug layer (#93/#94/#96): slug derivation (doubling fix),
|
|
4
|
+
# `slug #N` display, and effort_slug_resolve (number passthrough, branch match, ambiguity, no-match,
|
|
5
|
+
# slug:<slug> label vs title-derived precedence). Hermetic: a throwaway git repo with effort/* branches
|
|
6
|
+
# + a stubbed gh (no network/auth). Run: bash scripts/lib/effort-slug-test.sh
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
LIB="$ROOT/scripts/lib"
|
|
10
|
+
fail=0
|
|
11
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
12
|
+
rc() { # <label> <expected-rc> ; reads the just-run command's rc from $?
|
|
13
|
+
if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> rc '$2' want '$3'"; fail=1; fi; }
|
|
14
|
+
command -v git >/dev/null 2>&1 || { echo "effort-slug-test: git required" >&2; exit 1; }
|
|
15
|
+
|
|
16
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
17
|
+
|
|
18
|
+
# Stub gh so the issue-based fallback is deterministic (label lookup + title-derived).
|
|
19
|
+
stub="$tmp/bin"; mkdir -p "$stub"
|
|
20
|
+
cat > "$stub/gh" <<'SH'
|
|
21
|
+
#!/usr/bin/env bash
|
|
22
|
+
# issue list --label slug:explicit-handle → #207 ; title search → #205 "[Effort] 205 · [Core] Title Only Effort"
|
|
23
|
+
case "$*" in
|
|
24
|
+
*"--label slug:explicit-handle"*) echo "207" ;;
|
|
25
|
+
*"--label slug:"*) : ;; # unknown label → no match
|
|
26
|
+
*"in:title"*) printf '205\t[Effort] 205 · [Core] Title Only Effort\n' ;;
|
|
27
|
+
*) : ;;
|
|
28
|
+
esac
|
|
29
|
+
SH
|
|
30
|
+
chmod +x "$stub/gh"
|
|
31
|
+
export PATH="$stub:$PATH"
|
|
32
|
+
export EFFORT_REPO="o/r" KIT_REPO="o/r"
|
|
33
|
+
|
|
34
|
+
# shellcheck source=/dev/null
|
|
35
|
+
source "$LIB/effort-slug.sh"
|
|
36
|
+
|
|
37
|
+
# ── slug derivation (the #93 doubling fix) ─────────────────────────────────────────────────────
|
|
38
|
+
t "_eff_title_slug peels prefix + flow (parent)" \
|
|
39
|
+
"$(_eff_title_slug '[Effort] 93 · [Core] Slug handles for efforts')" "slug-handles-for-efforts"
|
|
40
|
+
t "_eff_title_slug peels prefix + flow (sub)" \
|
|
41
|
+
"$(_eff_title_slug '[Effort 93] 2 · [UI] Accept slug in commands')" "accept-slug-in-commands"
|
|
42
|
+
t "_eff_title_slug without a flow tag" \
|
|
43
|
+
"$(_eff_title_slug '[Effort] 12 · plain outcome name')" "plain-outcome-name"
|
|
44
|
+
t "_eff_slug lowercases + dashes arbitrary text" \
|
|
45
|
+
"$(_eff_slug 'Some Mixed CASE!!')" "some-mixed-case"
|
|
46
|
+
|
|
47
|
+
# ── display ────────────────────────────────────────────────────────────────────────────────────
|
|
48
|
+
t "effort_display renders slug #N" "$(effort_display 93 slug-handles)" "slug-handles #93"
|
|
49
|
+
t "effort_display without a slug" "$(effort_display 93)" "#93"
|
|
50
|
+
|
|
51
|
+
# ── effort_slug_resolve: number passthrough (canonical key, never re-mapped) ───────────────────
|
|
52
|
+
t "resolve passes a pure number through" "$(effort_slug_resolve 93)" "93"
|
|
53
|
+
effort_slug_resolve "" >/dev/null 2>&1; rc "resolve rejects empty input (rc 2)" "$?" "2"
|
|
54
|
+
|
|
55
|
+
# ── effort_slug_resolve: branch matching (local + remote effort/* refs) ────────────────────────
|
|
56
|
+
( cd "$tmp" && git init -q --bare remote.git )
|
|
57
|
+
git clone -q "$tmp/remote.git" "$tmp/work"
|
|
58
|
+
cd "$tmp/work" || exit 1
|
|
59
|
+
git -c user.email=t@t -c user.name=t commit -q --allow-empty -m init
|
|
60
|
+
git push -q origin HEAD:main
|
|
61
|
+
git branch effort/101-resolve-slug
|
|
62
|
+
git branch effort/102-accept-slug
|
|
63
|
+
git push -q origin effort/101-resolve-slug effort/102-accept-slug
|
|
64
|
+
# remote-only branch (delete the local ref so only refs/remotes/origin/… carries it)
|
|
65
|
+
git branch -D effort/102-accept-slug >/dev/null 2>&1
|
|
66
|
+
|
|
67
|
+
t "resolve a local branch slug" "$(effort_slug_resolve resolve-slug)" "101"
|
|
68
|
+
t "resolve a remote-only slug" "$(effort_slug_resolve accept-slug)" "102"
|
|
69
|
+
|
|
70
|
+
# ── ambiguity: two efforts share a slug → structured error, nonzero rc, no guess ───────────────
|
|
71
|
+
git branch effort/103-resolve-slug
|
|
72
|
+
out="$(effort_slug_resolve resolve-slug 2>&1)"; r=$?
|
|
73
|
+
rc "ambiguous slug returns nonzero rc" "$r" "1"
|
|
74
|
+
case "$out" in *ambiguous*) echo "ok: ambiguous slug explains itself" ;; *) echo "FAIL: ambiguous message: $out"; fail=1 ;; esac
|
|
75
|
+
git branch -D effort/103-resolve-slug >/dev/null 2>&1
|
|
76
|
+
|
|
77
|
+
# ── gh fallback: slug:<slug> label wins; title-derived used when no branch/label matches ───────
|
|
78
|
+
t "resolve via slug label (no branch)" "$(effort_slug_resolve explicit-handle)" "207"
|
|
79
|
+
t "resolve via title-derived (no branch)" "$(effort_slug_resolve title-only-effort)" "205"
|
|
80
|
+
|
|
81
|
+
# ── no match anywhere → nonzero rc ─────────────────────────────────────────────────────────────
|
|
82
|
+
out="$(effort_slug_resolve nope-not-here 2>&1)"; r=$?
|
|
83
|
+
rc "unknown slug returns nonzero rc" "$r" "1"
|
|
84
|
+
case "$out" in *"no effort matches"*) echo "ok: unknown slug explains itself" ;; *) echo "FAIL: no-match message: $out"; fail=1 ;; esac
|
|
85
|
+
|
|
86
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (effort-slug)" || echo "effort-slug: FAILURES"
|
|
87
|
+
exit "$fail"
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# effort-slug.sh — the effort *slug* layer (Effort #93). The GitHub issue NUMBER stays the canonical
|
|
4
|
+
# key; the slug is a DERIVED human handle that already lives in the branch name `effort/<N>-<slug>`.
|
|
5
|
+
# This file surfaces that handle: derive a slug from a title, render efforts as `slug #N`, and resolve
|
|
6
|
+
# a slug (or a number) back to the canonical effort number so commands can take either.
|
|
7
|
+
#
|
|
8
|
+
# Functions:
|
|
9
|
+
# _eff_slug <text> a short branch-safe slug (mirrors wt_start; shared with effort-ops)
|
|
10
|
+
# _eff_title_slug <effort title> slug derived from an effort title — peels the structural prefix
|
|
11
|
+
# ("[Effort] N · " / "[Effort N] M · ") and any leading [Flow] tag so
|
|
12
|
+
# the number/flow are NOT duplicated into the slug (#93 doubling fix)
|
|
13
|
+
# effort_display <N> [slug] render an effort as "slug #N" (or "#N" when no slug is known)
|
|
14
|
+
# effort_slug_resolve <slug|N> resolve a slug OR a number to the canonical effort number.
|
|
15
|
+
# pure-digits → passthrough; otherwise match effort/* branches
|
|
16
|
+
# (local + remote), then slug:<slug> labels, then open effort titles.
|
|
17
|
+
# no match → rc 1; ambiguous → rc 1; bad input → rc 2.
|
|
18
|
+
#
|
|
19
|
+
# Number stays canonical: a pure-digits argument is always treated as a number and passed through
|
|
20
|
+
# unchanged, so every existing `<N>` call keeps working. bash 3.2 compatible. Requires: git; gh (only
|
|
21
|
+
# for the issue-based fallback when no local/remote branch matches).
|
|
22
|
+
|
|
23
|
+
# Repo for the gh fallback — resolved from the same env effort.sh/kit-config populate.
|
|
24
|
+
_eff_slug_repo() { printf '%s' "${EFFORT_REPO:-${KIT_REPO:-}}"; }
|
|
25
|
+
|
|
26
|
+
# <text> → a short branch-safe slug (lowercase, [a-z0-9-], ≤40 chars). Mirrors wt_start / effort-ops.
|
|
27
|
+
_eff_slug() {
|
|
28
|
+
printf '%s' "$1" | sed -E 's/^\[[^]]+\][[:space:]]*//' | tr '[:upper:]' '[:lower:]' \
|
|
29
|
+
| sed -E 's/[^a-z0-9]+/-/g; s/^-+|-+$//g' | cut -c1-40
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# <effort title> → the human slug. Peels the structural prefix and one optional leading [Flow] tag
|
|
33
|
+
# BEFORE slugifying, so `[Effort] 93 · [Core] Slug handles` → `slug-handles` (not `93-core-slug-handles`,
|
|
34
|
+
# the cosmetic doubling that produced branches like `effort/98-98-core-…`). See #93 / sub #96.
|
|
35
|
+
_eff_title_slug() {
|
|
36
|
+
local t="$1"
|
|
37
|
+
# structural prefix: "[Effort] N · " (parent) or "[Effort N] M · " (sub)
|
|
38
|
+
t="$(printf '%s' "$t" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ ·? ?//')"
|
|
39
|
+
# one optional leading [Flow] tag
|
|
40
|
+
t="$(printf '%s' "$t" | sed -E 's/^\[[A-Za-z]+\][[:space:]]*//')"
|
|
41
|
+
_eff_slug "$t"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# <N> [slug] → "slug #N" for human output (the canonical handle is the number; the slug is the label).
|
|
45
|
+
effort_display() {
|
|
46
|
+
local n="$1" s="${2:-}"
|
|
47
|
+
if [ -n "$s" ]; then printf '%s #%s' "$s" "$n"; else printf '#%s' "$n"; fi
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# effort_slug_resolve <slug|N> → echo the canonical effort number on stdout (rc 0).
|
|
51
|
+
# - pure digits → passthrough (number stays canonical; never re-mapped).
|
|
52
|
+
# - otherwise normalize and match, in order: effort/* branches (local + remote), then (via gh)
|
|
53
|
+
# slug:<slug> labels, then title-derived slugs of open `[Effort]` issues.
|
|
54
|
+
# - no match → rc 1; >1 distinct match → rc 1 (ambiguous, never a wrong guess); empty/unusable → rc 2.
|
|
55
|
+
effort_slug_resolve() {
|
|
56
|
+
local input="${1:-}"
|
|
57
|
+
[ -n "$input" ] || { echo "effort_slug_resolve: <slug|N> required" >&2; return 2; }
|
|
58
|
+
case "$input" in
|
|
59
|
+
*[!0-9]*) : ;; # contains a non-digit → treat as a slug
|
|
60
|
+
*) printf '%s\n' "$input"; return 0 ;; # all digits → canonical number, passthrough
|
|
61
|
+
esac
|
|
62
|
+
|
|
63
|
+
local norm; norm="$(_eff_slug "$input")"
|
|
64
|
+
[ -n "$norm" ] || { echo "effort_slug_resolve: '$input' is not a usable slug" >&2; return 2; }
|
|
65
|
+
|
|
66
|
+
local matches="" ref n s
|
|
67
|
+
# 1. branches (local refs/heads + remote refs/remotes): effort/<N>-<slug>
|
|
68
|
+
while IFS= read -r ref; do
|
|
69
|
+
[ -n "$ref" ] || continue
|
|
70
|
+
n="$(printf '%s' "$ref" | sed -nE 's#^(.*/)?effort/([0-9]+)-(.*)$#\2#p')"
|
|
71
|
+
s="$(printf '%s' "$ref" | sed -nE 's#^(.*/)?effort/([0-9]+)-(.*)$#\3#p')"
|
|
72
|
+
[ -n "$n" ] || continue
|
|
73
|
+
[ "$s" = "$norm" ] && matches="$matches$n"$'\n'
|
|
74
|
+
done < <(git for-each-ref --format='%(refname:short)' refs/heads refs/remotes 2>/dev/null \
|
|
75
|
+
| grep -E '(^|/)effort/[0-9]+-' )
|
|
76
|
+
matches="$(printf '%s' "$matches" | grep -E '^[0-9]+$' | sort -un)"
|
|
77
|
+
|
|
78
|
+
# 2. gh fallback (only when no branch matched): slug:<slug> label first, then open effort titles.
|
|
79
|
+
if [ -z "$matches" ] && command -v gh >/dev/null 2>&1; then
|
|
80
|
+
local repo; repo="$(_eff_slug_repo)"
|
|
81
|
+
if [ -n "$repo" ]; then
|
|
82
|
+
matches="$(gh issue list --repo "$repo" --state open --label "slug:$norm" \
|
|
83
|
+
--json number -q '.[].number' 2>/dev/null | grep -E '^[0-9]+$' | sort -un)"
|
|
84
|
+
if [ -z "$matches" ]; then
|
|
85
|
+
local in it
|
|
86
|
+
matches="$(gh issue list --repo "$repo" --state open --search '[Effort] in:title' --limit 200 \
|
|
87
|
+
--json number,title -q '.[] | "\(.number)\t\(.title)"' 2>/dev/null \
|
|
88
|
+
| while IFS="$(printf '\t')" read -r in it; do
|
|
89
|
+
[ "$(_eff_title_slug "$it")" = "$norm" ] && printf '%s\n' "$in"
|
|
90
|
+
done | grep -E '^[0-9]+$' | sort -un)"
|
|
91
|
+
fi
|
|
92
|
+
fi
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
local count; count="$(printf '%s\n' "$matches" | grep -cE '^[0-9]+$')"
|
|
96
|
+
if [ "$count" -eq 0 ]; then
|
|
97
|
+
echo "effort_slug_resolve: no effort matches slug '$norm' (looked in effort/* branches, slug:* labels, open effort titles)" >&2
|
|
98
|
+
return 1
|
|
99
|
+
elif [ "$count" -gt 1 ]; then
|
|
100
|
+
echo "effort_slug_resolve: slug '$norm' is ambiguous — matches efforts $(printf '%s' "$matches" | tr '\n' ' ')— pass the number" >&2
|
|
101
|
+
return 1
|
|
102
|
+
fi
|
|
103
|
+
printf '%s\n' "$matches"
|
|
104
|
+
}
|
package/scripts/lib/effort.sh
CHANGED
|
@@ -106,6 +106,40 @@ effort_snapshot_subs() {
|
|
|
106
106
|
printf '%s' "$dir"
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
# ── Effort PR title — ONE composer shared by the verb + the skill (#121) ────────────────────────
|
|
110
|
+
# `cckit effort pr` (the verb) and /kit-effort-pr (the skill) previously composed different PR
|
|
111
|
+
# titles; they now both call effort_pr_title so an effort PR is titled identically no matter who
|
|
112
|
+
# opens it. The MANDATORY element is the [#N] effort id — a PR title without it is a review blocker
|
|
113
|
+
# (effort-model.md), enforced by effort_pr_title_check.
|
|
114
|
+
#
|
|
115
|
+
# effort_pr_title <num> <name> [role_display] — compose the canonical title:
|
|
116
|
+
# effort_pr_title 115 "adoption hardening" -> "[#115] adoption hardening"
|
|
117
|
+
# effort_pr_title 115 "adoption hardening" "Tech Lead" -> "[Tech Lead] [#115] adoption hardening"
|
|
118
|
+
# A full parent title ("[Effort] 115 · [Core] adoption hardening") is accepted too — the
|
|
119
|
+
# "[Effort] N · " prefix is peeled so the id is never duplicated.
|
|
120
|
+
effort_pr_title() {
|
|
121
|
+
local num="${1:-}" name="${2:-}" role="${3:-}"
|
|
122
|
+
num="${num#\#}"
|
|
123
|
+
name="$(printf '%s' "$name" | sed -E 's/^\[Effort\] [0-9]+ · ?//')"
|
|
124
|
+
[ -n "$name" ] || name="effort"
|
|
125
|
+
if [ -n "$role" ]; then printf '[%s] [#%s] %s' "$role" "$num" "$name"
|
|
126
|
+
else printf '[#%s] %s' "$num" "$name"; fi
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
# effort_pr_title_check <title> [num] — rc 0 iff <title> carries the effort id token [#N] (the exact
|
|
130
|
+
# [#num] when given, else any [#digits]). Prints the reason + rc 1 when it doesn't, so both the verb
|
|
131
|
+
# and the skill can refuse to open a PR whose title lacks the effort id.
|
|
132
|
+
effort_pr_title_check() {
|
|
133
|
+
local title="${1:-}" num="${2:-}"
|
|
134
|
+
if [ -n "$num" ]; then
|
|
135
|
+
num="${num#\#}"
|
|
136
|
+
case "$title" in *"[#$num]"*) return 0 ;; esac
|
|
137
|
+
echo "effort_pr_title_check: PR title lacks the [#$num] effort id: '$title'" >&2; return 1
|
|
138
|
+
fi
|
|
139
|
+
printf '%s' "$title" | grep -qE '\[#[0-9]+\]' && return 0
|
|
140
|
+
echo "effort_pr_title_check: PR title lacks a [#N] effort id: '$title'" >&2; return 1
|
|
141
|
+
}
|
|
142
|
+
|
|
109
143
|
# ── Effort-title rule — concise, jargon-free, flow-tagged ──────────────────────────────────────────
|
|
110
144
|
# The board must say what an effort delivers and which FLOW it belongs to. So the `<Name>` part of an
|
|
111
145
|
# effort/sub title is a short plain-language outcome with an optional leading `[Flow]` tag from a
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# gh-project-test.sh — covers the board owner-type resolution adoption needs (#118). A Projects v2
|
|
4
|
+
# board can live under a USER login or an ORGANIZATION login, and each needs a different GraphQL root
|
|
5
|
+
# (user(login:) vs organization(login:)). A user-only query silently returns null for an org board.
|
|
6
|
+
# Covered: _ghp_owner_root resolution, kit-config exporting KIT_PROJECT_OWNER_TYPE, and
|
|
7
|
+
# capture-project-ids.sh selecting the matching root end-to-end (stubbed gh — no network).
|
|
8
|
+
# Run: bash scripts/lib/gh-project-test.sh
|
|
9
|
+
set -u
|
|
10
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
11
|
+
LIB="$ROOT/scripts/lib"
|
|
12
|
+
fail=0
|
|
13
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
14
|
+
has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> '$2' lacks '$3'"; fail=1 ;; esac; }
|
|
15
|
+
command -v jq >/dev/null 2>&1 || { echo "gh-project-test: jq required — skipping"; exit 0; }
|
|
16
|
+
|
|
17
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
18
|
+
|
|
19
|
+
# ── _ghp_owner_root resolves from KIT_PROJECT_OWNER_TYPE ───────────────────────────────────────
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
( KIT_PROJECT_OWNER_TYPE=organization; source "$LIB/gh-project.sh"; [ "$(_ghp_owner_root)" = organization ] ) \
|
|
22
|
+
&& echo "ok: owner_root=organization for org type" || { echo "FAIL: org owner_root"; fail=1; }
|
|
23
|
+
( KIT_PROJECT_OWNER_TYPE=org; source "$LIB/gh-project.sh"; [ "$(_ghp_owner_root)" = organization ] ) \
|
|
24
|
+
&& echo "ok: owner_root=organization for 'org' shorthand" || { echo "FAIL: org shorthand"; fail=1; }
|
|
25
|
+
( unset KIT_PROJECT_OWNER_TYPE; KIT_CONFIG=/nonexistent; source "$LIB/gh-project.sh"; [ "$(_ghp_owner_root)" = user ] ) \
|
|
26
|
+
&& echo "ok: owner_root=user by default" || { echo "FAIL: default user owner_root"; fail=1; }
|
|
27
|
+
|
|
28
|
+
# ── kit-config exports KIT_PROJECT_OWNER_TYPE from config ──────────────────────────────────────
|
|
29
|
+
printf '%s' '{"github":{"projectOwnerType":"organization"}}' > "$tmp/org.json"
|
|
30
|
+
got="$(KIT_CONFIG="$tmp/org.json" bash -c "source '$LIB/kit-config.sh'; load_kit_config >/dev/null 2>&1; printf '%s' \"\$KIT_PROJECT_OWNER_TYPE\"")"
|
|
31
|
+
t "kit-config exports owner type from config" "$got" "organization"
|
|
32
|
+
printf '%s' '{"github":{}}' > "$tmp/none.json"
|
|
33
|
+
got="$(KIT_CONFIG="$tmp/none.json" bash -c "source '$LIB/kit-config.sh'; load_kit_config >/dev/null 2>&1; printf '%s' \"\$KIT_PROJECT_OWNER_TYPE\"")"
|
|
34
|
+
t "kit-config defaults owner type to user" "$got" "user"
|
|
35
|
+
|
|
36
|
+
# ── capture-project-ids.sh selects the matching GraphQL root (stubbed gh) ───────────────────────
|
|
37
|
+
# Isolated scripts dir: a copy of the script + a symlink to the real lib, so $0-relative sourcing +
|
|
38
|
+
# OUT path stay inside tmp. A stub gh detects the query root and returns matching-shaped JSON.
|
|
39
|
+
mkdir -p "$tmp/scripts" "$tmp/bin"
|
|
40
|
+
cp "$ROOT/scripts/capture-project-ids.sh" "$tmp/scripts/"
|
|
41
|
+
ln -s "$LIB" "$tmp/scripts/lib"
|
|
42
|
+
cat > "$tmp/bin/gh" <<'SH'
|
|
43
|
+
#!/usr/bin/env bash
|
|
44
|
+
# Record the query, then emit JSON under whichever root the query selected.
|
|
45
|
+
q=""; for a in "$@"; do case "$a" in query=*) q="${a#query=}" ;; esac; done
|
|
46
|
+
printf '%s\n' "$q" >> "$GH_QUERY_LOG"
|
|
47
|
+
if printf '%s' "$q" | grep -q 'organization(login'; then root=organization; else root=user; fi
|
|
48
|
+
cat <<JSON
|
|
49
|
+
{"data":{"$root":{"projectV2":{"id":"PVT_org123","fields":{"nodes":[
|
|
50
|
+
{"__typename":"ProjectV2SingleSelectField","id":"F_status","name":"Status","options":[{"id":"O_todo","name":"Todo"}]},
|
|
51
|
+
{"__typename":"ProjectV2FieldCommon","id":"F_plan","name":"Plan Link"}
|
|
52
|
+
]}}}}}
|
|
53
|
+
JSON
|
|
54
|
+
SH
|
|
55
|
+
chmod +x "$tmp/bin/gh"
|
|
56
|
+
|
|
57
|
+
run_capture() { # <owner-type>
|
|
58
|
+
printf '%s' "{\"github\":{\"projectsV2\":true,\"owner\":\"acme\",\"projectNumber\":3,\"projectOwnerType\":\"$1\"}}" > "$tmp/cfg.json"
|
|
59
|
+
: > "$tmp/qlog"
|
|
60
|
+
GH_QUERY_LOG="$tmp/qlog" KIT_CONFIG="$tmp/cfg.json" PATH="$tmp/bin:$PATH" \
|
|
61
|
+
bash "$tmp/scripts/capture-project-ids.sh" >/dev/null 2>&1
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
run_capture organization
|
|
65
|
+
rc=$?
|
|
66
|
+
t "capture rc 0 (org board)" "$rc" "0"
|
|
67
|
+
has "capture uses organization root for an org board" "$(cat "$tmp/qlog")" "organization(login"
|
|
68
|
+
[ -f "$tmp/scripts/.project-ids.env" ] && has "org capture wrote PROJECT_ID" "$(cat "$tmp/scripts/.project-ids.env")" "PROJECT_ID=PVT_org123" || { echo "FAIL: no env written (org)"; fail=1; }
|
|
69
|
+
has "org capture wrote a field id" "$(cat "$tmp/scripts/.project-ids.env" 2>/dev/null)" "STATUS_FIELD_ID=F_status"
|
|
70
|
+
rm -f "$tmp/scripts/.project-ids.env"
|
|
71
|
+
|
|
72
|
+
run_capture user
|
|
73
|
+
has "capture uses user root for a user board" "$(cat "$tmp/qlog")" "user(login"
|
|
74
|
+
|
|
75
|
+
# ── project_issue_status: read an issue's board Status via the cheap issue.projectItems query (#124) ─
|
|
76
|
+
mkdir -p "$tmp/bin2"
|
|
77
|
+
cat > "$tmp/bin2/gh" <<'SH'
|
|
78
|
+
#!/usr/bin/env bash
|
|
79
|
+
# The issue.projectItems Status query: issue is "In Progress" on project #3 (and Todo on some other).
|
|
80
|
+
cat <<'JSON'
|
|
81
|
+
{"data":{"repository":{"issue":{"projectItems":{"nodes":[
|
|
82
|
+
{"project":{"number":7},"fieldValueByName":{"name":"Todo"}},
|
|
83
|
+
{"project":{"number":3},"fieldValueByName":{"name":"In Progress"}}
|
|
84
|
+
]}}}}}
|
|
85
|
+
JSON
|
|
86
|
+
SH
|
|
87
|
+
chmod +x "$tmp/bin2/gh"
|
|
88
|
+
st="$(PATH="$tmp/bin2:$PATH" KIT_REPO="acme/app" KIT_PROJECT_NUMBER=3 bash -c "source '$LIB/gh-project.sh'; project_issue_status 42")"
|
|
89
|
+
t "project_issue_status returns the board Status for our project" "$st" "In Progress"
|
|
90
|
+
# unresolved repo/number -> non-zero, no guess.
|
|
91
|
+
PATH="$tmp/bin2:$PATH" KIT_REPO="" KIT_PROJECT_NUMBER="" bash -c "source '$LIB/gh-project.sh'; project_issue_status 42" >/dev/null 2>&1
|
|
92
|
+
t "project_issue_status fails (rc 1) with unresolved repo/number" "$?" "1"
|
|
93
|
+
|
|
94
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (gh-project)" || echo "gh-project: FAILURES"
|
|
95
|
+
exit "$fail"
|
|
@@ -139,10 +139,10 @@ _ghp_resolve_pnum() {
|
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
# Resolve the project OWNER TYPE — "organization" or "user" (default "user").
|
|
142
|
-
#
|
|
143
|
-
#
|
|
144
|
-
# own card via the CHEAP issue.projectItems lookup (project_find_item_by_issue),
|
|
142
|
+
# A board can live under a user login OR an organization login. An org-owned board is what lets a
|
|
143
|
+
# single issue see its own card via the CHEAP issue.projectItems lookup (project_find_item_by_issue),
|
|
145
144
|
# so every board GraphQL query must branch on this: organization(login:) vs user(login:).
|
|
145
|
+
# Prefers the exported KIT_PROJECT_OWNER_TYPE (set by kit-config from github.projectOwnerType).
|
|
146
146
|
_ghp_resolve_owner_type() {
|
|
147
147
|
[[ -n "${KIT_PROJECT_OWNER_TYPE:-}" ]] && { printf '%s' "$KIT_PROJECT_OWNER_TYPE"; return 0; }
|
|
148
148
|
local cfg="${KIT_CONFIG:-$SCRIPT_DIR/../.claude/kit.config.json}" t=""
|
|
@@ -176,10 +176,9 @@ _ghp_resolve_repo() {
|
|
|
176
176
|
# Prints the item node ID on stdout, or nothing if the issue genuinely isn't on the board.
|
|
177
177
|
#
|
|
178
178
|
# Instead of paginating the WHOLE board (the old 330+-item loop), this asks the ISSUE for its
|
|
179
|
-
# own project cards (issue.projectItems) and filters by project number.
|
|
180
|
-
#
|
|
181
|
-
#
|
|
182
|
-
# An issue belongs to few projects, so first:20 covers it without a loop.
|
|
179
|
+
# own project cards (issue.projectItems) and filters by project number. issue.projectItems surfaces
|
|
180
|
+
# an issue's cards cheaply (O(1) per issue) whether the board is user- or org-owned, so this finder
|
|
181
|
+
# never paginates. An issue belongs to few projects, so first:20 covers it without a loop.
|
|
183
182
|
project_find_item_by_issue() {
|
|
184
183
|
local issue_num="$1"
|
|
185
184
|
local pnum="${2:-$(_ghp_resolve_pnum)}"
|
|
@@ -210,3 +209,19 @@ project_find_item_by_issue() {
|
|
|
210
209
|
'.data.repository.issue.projectItems.nodes[] | select(.project.number==$n) | .id' 2>/dev/null | head -1)
|
|
211
210
|
echo "$item_id"
|
|
212
211
|
}
|
|
212
|
+
|
|
213
|
+
# project_issue_status <issue_number> [<project_number>] — echo an issue's Project Status field value
|
|
214
|
+
# on OUR board ("Todo" / "In Progress" / "Done" / …), or empty when the issue isn't on the board.
|
|
215
|
+
# The cheap issue.projectItems lookup, same as project_find_item_by_issue. A claim precheck reads this
|
|
216
|
+
# before starting an issue so it can warn on a collision (another session already In Progress). #124.
|
|
217
|
+
project_issue_status() {
|
|
218
|
+
local issue_num="$1" pnum="${2:-$(_ghp_resolve_pnum)}" repo owner name resp
|
|
219
|
+
repo="$(_ghp_resolve_repo)"; owner="${repo%%/*}"; name="${repo##*/}"
|
|
220
|
+
[ -n "$owner" ] && [ -n "$name" ] && [ -n "$pnum" ] || return 1
|
|
221
|
+
resp="$(gh api graphql \
|
|
222
|
+
-f query='query($o:String!,$r:String!,$n:Int!){repository(owner:$o,name:$r){issue(number:$n){projectItems(first:20){nodes{project{number} fieldValueByName(name:"Status"){...on ProjectV2ItemFieldSingleSelectValue{name}}}}}}}' \
|
|
223
|
+
-F o="$owner" -F r="$name" -F n="$issue_num" 2>/dev/null)" || return 1
|
|
224
|
+
printf '%s' "$resp" | jq -r --argjson n "$pnum" \
|
|
225
|
+
'.data.repository.issue.projectItems.nodes[]? | select(.project.number==$n) | .fieldValueByName.name // empty' \
|
|
226
|
+
2>/dev/null | head -1
|
|
227
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# git-remote-test.sh — covers deriving the project's repo identity from the git remote (#73), so
|
|
4
|
+
# NAME / slug / wing come from the ACTUAL repo name (not a cloned/renamed directory basename). Also
|
|
5
|
+
# checks the host-agnostic URL parsing (ssh, https, GHE/GitLab). Hermetic: a throwaway git repo with
|
|
6
|
+
# a fake remote. Run: bash scripts/lib/git-remote-test.sh
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
LIB="$ROOT/scripts/lib"
|
|
10
|
+
fail=0
|
|
11
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
12
|
+
rc() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> rc '$2' want '$3'"; fail=1; fi; }
|
|
13
|
+
command -v git >/dev/null 2>&1 || { echo "git-remote-test: git required" >&2; exit 1; }
|
|
14
|
+
|
|
15
|
+
# shellcheck source=/dev/null
|
|
16
|
+
. "$LIB/git-remote.sh"
|
|
17
|
+
|
|
18
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
19
|
+
cd "$tmp"; git init -q proj-dir-renamed; cd proj-dir-renamed # dir name != repo name on purpose
|
|
20
|
+
|
|
21
|
+
# no remote yet -> rc 1, empty (so callers fall back to the basename)
|
|
22
|
+
out="$(git_remote_slug 2>/dev/null)"; r=$?
|
|
23
|
+
rc "no remote -> rc 1" "$r" "1"
|
|
24
|
+
t "no remote -> empty" "$out" ""
|
|
25
|
+
|
|
26
|
+
set_remote() { git remote remove origin 2>/dev/null; git remote add origin "$1"; }
|
|
27
|
+
|
|
28
|
+
# ssh form
|
|
29
|
+
set_remote "git@github.com:acme/actual-repo.git"
|
|
30
|
+
t "ssh: slug" "$(git_remote_slug)" "acme/actual-repo"
|
|
31
|
+
t "ssh: repo name" "$(git_remote_repo_name)" "actual-repo"
|
|
32
|
+
t "ssh: owner" "$(git_remote_owner)" "acme"
|
|
33
|
+
|
|
34
|
+
# https form with .git
|
|
35
|
+
set_remote "https://github.com/acme/actual-repo.git"
|
|
36
|
+
t "https: slug" "$(git_remote_slug)" "acme/actual-repo"
|
|
37
|
+
t "https: repo name" "$(git_remote_repo_name)" "actual-repo"
|
|
38
|
+
|
|
39
|
+
# https without .git
|
|
40
|
+
set_remote "https://github.com/acme/actual-repo"
|
|
41
|
+
t "https no .git: repo name" "$(git_remote_repo_name)" "actual-repo"
|
|
42
|
+
|
|
43
|
+
# a non-GitHub host (GitLab) still parses (host-agnostic)
|
|
44
|
+
set_remote "git@gitlab.example.com:group/my-service.git"
|
|
45
|
+
t "GHE/GitLab: owner" "$(git_remote_owner)" "group"
|
|
46
|
+
t "GHE/GitLab: repo name" "$(git_remote_repo_name)" "my-service"
|
|
47
|
+
|
|
48
|
+
# ssh:// scheme form
|
|
49
|
+
set_remote "ssh://git@github.com/acme/another.git"
|
|
50
|
+
t "ssh:// scheme: repo name" "$(git_remote_repo_name)" "another"
|
|
51
|
+
|
|
52
|
+
# The whole point: repo name comes from the remote, NOT the (renamed) directory basename.
|
|
53
|
+
t "repo name != directory basename" "$(git_remote_repo_name)" "another"
|
|
54
|
+
[ "$(basename "$PWD")" = "proj-dir-renamed" ] && echo "ok: directory basename is indeed different" || { echo "FAIL: dir basename"; fail=1; }
|
|
55
|
+
|
|
56
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (git-remote)" || echo "git-remote: FAILURES"
|
|
57
|
+
exit "$fail"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# git-remote.sh — derive the project's repo identity from its git remote (#73). The local directory
|
|
4
|
+
# is often cloned/renamed to something other than the repo name, so NAME / slug / wing should come
|
|
5
|
+
# from the ACTUAL remote repo name; the directory basename is only the LAST resort. Pure git + sed —
|
|
6
|
+
# no gh, no network, host-agnostic (github.com, GHE, GitLab, ssh/https). bash 3.2 + zsh compatible.
|
|
7
|
+
#
|
|
8
|
+
# git_remote_slug [dir] -> "owner/repo" from origin (rc 1 + empty when no remote)
|
|
9
|
+
# git_remote_repo_name [dir] -> "repo"
|
|
10
|
+
# git_remote_owner [dir] -> "owner"
|
|
11
|
+
|
|
12
|
+
git_remote_slug() {
|
|
13
|
+
local dir="${1:-$PWD}" url
|
|
14
|
+
url="$(git -C "$dir" remote get-url origin 2>/dev/null || true)"
|
|
15
|
+
[ -n "$url" ] || return 1
|
|
16
|
+
# Strip any scheme/host prefix (git@host:, ssh://git@host/, https://host/) and the trailing .git.
|
|
17
|
+
printf '%s' "$url" | sed -E 's#^[a-z]+://[^/]+/##; s#^git@[^:]+:##; s#\.git$##; s#/$##'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
git_remote_repo_name() { local s; s="$(git_remote_slug "${1:-$PWD}")" || return 1; printf '%s' "${s##*/}"; }
|
|
21
|
+
git_remote_owner() { local s; s="$(git_remote_slug "${1:-$PWD}")" || return 1; printf '%s' "${s%%/*}"; }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# kit-config-test.sh — covers load_kit_config resolution that adoption depends on. Today: the
|
|
4
|
+
# integration-branch fallback chain (#117) — a host project that names its integration branch under
|
|
5
|
+
# an alternate key (integrationBranch / flow) must still resolve, not silently fall back to "main".
|
|
6
|
+
# Hermetic: throwaway config files pointed at via KIT_CONFIG. Run: bash scripts/lib/kit-config-test.sh
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
LIB="$ROOT/scripts/lib"
|
|
10
|
+
fail=0
|
|
11
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
12
|
+
command -v jq >/dev/null 2>&1 || { echo "kit-config-test: jq required — skipping"; exit 0; }
|
|
13
|
+
|
|
14
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
15
|
+
|
|
16
|
+
# base_branch_for <json> — resolve KIT_BASE_BRANCH for a given github config, hermetically.
|
|
17
|
+
base_branch_for() {
|
|
18
|
+
local json="$1" d; d="$(mktemp -d "$tmp/cfg.XXXXXX")"
|
|
19
|
+
printf '%s' "$json" > "$d/cckit.config.json"
|
|
20
|
+
KIT_CONFIG="$d/cckit.config.json" bash -c "source '$LIB/kit-config.sh'; load_kit_config >/dev/null 2>&1; printf '%s' \"\$KIT_BASE_BRANCH\""
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# baseBranch is canonical and wins over the alternate keys.
|
|
24
|
+
t "baseBranch wins" \
|
|
25
|
+
"$(base_branch_for '{"github":{"baseBranch":"develop","integrationBranch":"x","flow":"y"}}')" "develop"
|
|
26
|
+
# integrationBranch is honored when baseBranch is absent (older/alternate host config).
|
|
27
|
+
t "integrationBranch fallback" \
|
|
28
|
+
"$(base_branch_for '{"github":{"integrationBranch":"integration","flow":"y"}}')" "integration"
|
|
29
|
+
# flow is the last named fallback before the default.
|
|
30
|
+
t "flow fallback" \
|
|
31
|
+
"$(base_branch_for '{"github":{"flow":"trunk"}}')" "trunk"
|
|
32
|
+
# nothing set -> "main", the safe default.
|
|
33
|
+
t "default main when unset" \
|
|
34
|
+
"$(base_branch_for '{"github":{}}')" "main"
|
|
35
|
+
|
|
36
|
+
[ "$fail" -eq 0 ] && echo "ALL OK (kit-config)" || echo "kit-config: FAILURES"
|
|
37
|
+
exit "$fail"
|
|
@@ -6,13 +6,24 @@
|
|
|
6
6
|
# Per-folder overrides: any .claudekit/config.json in an ancestor directory is deep-merged over the
|
|
7
7
|
# project config, nearest-wins (like .editorconfig). Projects with no .claudekit/ behave unchanged.
|
|
8
8
|
|
|
9
|
+
# Source the ONE shared config-path resolver (config-path.sh, #69). Self-locate portably: BASH_SOURCE
|
|
10
|
+
# is bash-only (empty under zsh, where dirname "" -> CWD and the lib is sought in the wrong dir), so
|
|
11
|
+
# use zsh's %x prompt escape there. eval keeps bash from parsing the zsh-only syntax.
|
|
12
|
+
if ! command -v kit_config_path >/dev/null 2>&1; then
|
|
13
|
+
if [ -n "${BASH_SOURCE:-}" ]; then _kc_self="${BASH_SOURCE[0]}"
|
|
14
|
+
elif [ -n "${ZSH_VERSION:-}" ]; then eval '_kc_self="${(%):-%x}"'
|
|
15
|
+
else _kc_self="$0"; fi
|
|
16
|
+
_kc_dir="$(cd "$(dirname "$_kc_self")" && pwd)"
|
|
17
|
+
# shellcheck source=/dev/null
|
|
18
|
+
[ -f "$_kc_dir/config-path.sh" ] && . "$_kc_dir/config-path.sh"
|
|
19
|
+
unset _kc_self _kc_dir
|
|
20
|
+
fi
|
|
21
|
+
|
|
9
22
|
load_kit_config() {
|
|
10
|
-
# Resolve the project config
|
|
11
|
-
#
|
|
12
|
-
local cfg="$
|
|
13
|
-
|
|
14
|
-
if [[ -f cckit.config.json ]]; then cfg="cckit.config.json"; else cfg=".claude/kit.config.json"; fi
|
|
15
|
-
fi
|
|
23
|
+
# Resolve the project config through the ONE shared resolver: an explicit KIT_CONFIG wins, else
|
|
24
|
+
# walk up for a root cckit.config.json or a .claude/kit.config.json.
|
|
25
|
+
local cfg; cfg="$(kit_config_path 2>/dev/null || true)"
|
|
26
|
+
[[ -n "$cfg" ]] || cfg=".claude/kit.config.json"
|
|
16
27
|
if [[ ! -f "$cfg" ]]; then
|
|
17
28
|
echo "✗ $cfg not found. Run /kit-init (or scripts/init.sh) first." >&2
|
|
18
29
|
return 1
|
|
@@ -30,10 +41,16 @@ load_kit_config() {
|
|
|
30
41
|
|
|
31
42
|
export KIT_REPO="$(jq -r '.github.repo' "$cfg")"
|
|
32
43
|
export KIT_OWNER="$(jq -r '.github.owner' "$cfg")"
|
|
33
|
-
|
|
44
|
+
# Integration branch, resolved through a fallback chain so a host project that names its
|
|
45
|
+
# integration branch under an older/alternate key still works on adoption: baseBranch (canonical)
|
|
46
|
+
# -> integrationBranch -> flow -> "main". First non-null wins (#117).
|
|
47
|
+
export KIT_BASE_BRANCH="$(jq -r '.github.baseBranch // .github.integrationBranch // .github.flow // "main"' "$cfg")"
|
|
34
48
|
export KIT_PROJECTS_V2="$(jq -r '.github.projectsV2' "$cfg")"
|
|
35
49
|
export KIT_PROJECT_NUMBER="$(jq -r '.github.projectNumber' "$cfg")"
|
|
36
50
|
export KIT_PROJECT_TITLE="$(jq -r '.github.projectTitle' "$cfg")"
|
|
51
|
+
# Board owner type — "user" or "organization". A board can live under a user OR an org login, and
|
|
52
|
+
# every projectV2-by-number GraphQL query must select the matching root, so capture this once (#118).
|
|
53
|
+
export KIT_PROJECT_OWNER_TYPE="$(jq -r '.github.projectOwnerType // "user"' "$cfg")"
|
|
37
54
|
|
|
38
55
|
export KIT_PLANS_FORMAT="$(jq -r '.plans.format' "$cfg")"
|
|
39
56
|
export KIT_PLANS_DIR="$(jq -r '.plans.dir' "$cfg")"
|
|
@@ -83,11 +100,14 @@ _kit_apply_claudekit_overlays() {
|
|
|
83
100
|
merged="$(jq -s '.[0] * .[1]' <(printf '%s' "$merged") "$o" 2>/dev/null || printf '%s' "$merged")"
|
|
84
101
|
done
|
|
85
102
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export
|
|
91
|
-
export
|
|
103
|
+
# Named `_kit_cfg_get`, not `g`: a one-letter `g` collides with a universal `alias g=git` when
|
|
104
|
+
# this file is sourced under zsh (interactive shells) -> "defining function based on alias" parse
|
|
105
|
+
# error. A namespaced name can never be an alias.
|
|
106
|
+
_kit_cfg_get() { printf '%s' "$merged" | jq -r "$1" 2>/dev/null; }
|
|
107
|
+
export KIT_LANG="$(_kit_cfg_get '.project.language // env.KIT_LANG')"
|
|
108
|
+
export KIT_PLANS_FORMAT="$(_kit_cfg_get '.plans.format // env.KIT_PLANS_FORMAT')"
|
|
109
|
+
export KIT_ANNOTATE_ENABLED="$(_kit_cfg_get '.annotate.enabled // false')"
|
|
110
|
+
export KIT_ANNOTATE_BACKEND="$(_kit_cfg_get '.annotate.backend // ""')"
|
|
111
|
+
export KIT_ANNOTATE_FRAMEWORK="$(_kit_cfg_get '.annotate.framework // ""')"
|
|
92
112
|
export KIT_EFFECTIVE_CONFIG="$merged"
|
|
93
113
|
}
|
|
@@ -43,8 +43,10 @@ emit_event() {
|
|
|
43
43
|
[[ -n "$payload" ]] || payload='{}'
|
|
44
44
|
command -v jq >/dev/null 2>&1 || return 0
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
path
|
|
46
|
+
# `logpath`, not `path`: under zsh `path` is tied to PATH (special array); assigning to a bare
|
|
47
|
+
# `path` local would clobber the command search path. A namespaced name is inert.
|
|
48
|
+
local logpath ts line
|
|
49
|
+
logpath="$(kit_events_path)" || return 0
|
|
48
50
|
ts="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
49
51
|
|
|
50
52
|
# Build the line with jq so payload is validated + the record is well-formed.
|
|
@@ -58,5 +60,5 @@ emit_event() {
|
|
|
58
60
|
'{ts:$ts, type:$type, op:$op, payload:{note:$raw}}' 2>/dev/null)" || return 0
|
|
59
61
|
|
|
60
62
|
# Single-writer append; >> is atomic for short lines on local fs.
|
|
61
|
-
printf '%s\n' "$line" >> "$
|
|
63
|
+
printf '%s\n' "$line" >> "$logpath" 2>/dev/null || return 0
|
|
62
64
|
}
|