@jeiemgi/cckit 0.6.1 → 0.7.1
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 +34 -3
- package/README.md +86 -5
- package/bin/cckit +72 -3
- package/cckit.config.json +6 -1
- package/kit.config.schema.json +26 -1
- package/package.json +1 -1
- package/profiles/automation.json +2 -1
- package/profiles/content.json +2 -1
- package/profiles/minimal.json +2 -1
- package/profiles/research.json +2 -1
- package/profiles/software.json +2 -1
- package/scripts/init.sh +31 -1
- package/scripts/lib/board-view-test.sh +1 -0
- package/scripts/lib/board-view.sh +1 -0
- package/scripts/lib/captain-test.sh +62 -0
- package/scripts/lib/captain.sh +105 -17
- package/scripts/lib/cckit-output.sh +1 -0
- package/scripts/lib/commitlint.sh +1 -0
- package/scripts/lib/config-path-test.sh +1 -0
- package/scripts/lib/config-path.sh +1 -0
- package/scripts/lib/copilot-test.sh +1 -0
- package/scripts/lib/copilot.sh +1 -0
- package/scripts/lib/effort-dispatch-test.sh +10 -0
- package/scripts/lib/effort-flows-test.sh +1 -0
- package/scripts/lib/effort-metrics-test.sh +1 -0
- package/scripts/lib/effort-metrics.sh +1 -0
- package/scripts/lib/effort-ops-test.sh +360 -0
- package/scripts/lib/effort-ops.sh +372 -16
- package/scripts/lib/effort-parity-test.sh +1 -0
- package/scripts/lib/effort-plan.sh +1 -0
- package/scripts/lib/effort-slug-test.sh +32 -0
- package/scripts/lib/effort-slug.sh +72 -8
- package/scripts/lib/effort.sh +1 -0
- package/scripts/lib/engine-adapter.sh +1 -0
- package/scripts/lib/errors-header-test.sh +86 -0
- package/scripts/lib/gh-log.sh +1 -0
- package/scripts/lib/gh-project-test.sh +1 -0
- package/scripts/lib/gh-project.sh +1 -0
- package/scripts/lib/git-remote-test.sh +1 -0
- package/scripts/lib/git-remote.sh +1 -0
- package/scripts/lib/handoff.sh +23 -2
- package/scripts/lib/kit-brief-test.sh +292 -0
- package/scripts/lib/kit-brief.sh +376 -0
- package/scripts/lib/kit-cli-test.sh +1 -0
- package/scripts/lib/kit-cli.sh +1 -0
- package/scripts/lib/kit-config-resolve.sh +1 -0
- package/scripts/lib/kit-config-test.sh +14 -0
- package/scripts/lib/kit-config.sh +7 -0
- package/scripts/lib/kit-engine-test.sh +1 -0
- package/scripts/lib/kit-events.sh +1 -0
- package/scripts/lib/kit-gc-test.sh +125 -0
- package/scripts/lib/kit-gc.sh +193 -5
- package/scripts/lib/kit-interview-test.sh +1 -0
- package/scripts/lib/kit-interview.sh +1 -0
- package/scripts/lib/kit-lib-test.sh +226 -0
- package/scripts/lib/kit-lib.sh +308 -0
- package/scripts/lib/kit-local.sh +1 -0
- package/scripts/lib/kit-manifest.sh +1 -0
- package/scripts/lib/kit-mode-test.sh +1 -0
- package/scripts/lib/kit-mode.sh +1 -0
- package/scripts/lib/kit-msg-test.sh +1 -0
- package/scripts/lib/kit-msg.sh +1 -0
- package/scripts/lib/kit-operate.sh +1 -0
- package/scripts/lib/kit-profile-test.sh +1 -0
- package/scripts/lib/kit-profile.sh +1 -0
- package/scripts/lib/kit-state-test.sh +89 -0
- package/scripts/lib/kit-state.sh +61 -0
- package/scripts/lib/kit-status-test.sh +233 -0
- package/scripts/lib/kit-status.sh +415 -0
- package/scripts/lib/kit-task-ops-test.sh +1 -0
- package/scripts/lib/kit-task-ops.sh +1 -0
- package/scripts/lib/next.sh +1 -0
- package/scripts/lib/plan-machine-test.sh +54 -0
- package/scripts/lib/plan-machine.sh +86 -25
- package/scripts/lib/plan-next-test.sh +1 -0
- package/scripts/lib/plan-next.sh +1 -0
- package/scripts/lib/pr-evidence-test.sh +259 -0
- package/scripts/lib/pr-evidence.sh +220 -35
- package/scripts/lib/project-scan.sh +1 -0
- package/scripts/lib/react-detect.sh +1 -0
- package/scripts/lib/render-test.sh +1 -0
- package/scripts/lib/render.sh +1 -0
- package/scripts/lib/role-identity.sh +1 -0
- package/scripts/lib/secret-guard.sh +21 -1
- package/scripts/lib/toon.sh +1 -0
- package/scripts/lib/ui.sh +1 -0
- package/scripts/lib/version-bump-test.sh +1 -0
- package/scripts/lib/version-bump.sh +1 -0
- package/scripts/lib/worktree-bootstrap-test.sh +220 -0
- package/scripts/lib/worktree-issue-test.sh +15 -1
- package/scripts/lib/worktree-issue.sh +23 -8
- package/scripts/lib/worktree-start.sh +191 -7
- package/scripts/lib/zsh-safety-test.sh +10 -0
- package/scripts/portable-test.sh +13 -2
- package/scripts/self-install-test.sh +282 -0
- package/scripts/setup-labels.sh +1 -0
- package/scripts/status.sh +25 -10
- package/skills/kit-cleanup/SKILL.md +83 -0
- package/skills/kit-effort-close/SKILL.md +3 -0
- package/skills/kit-effort-new/SKILL.md +7 -0
- package/skills/kit-effort-start/SKILL.md +39 -4
- package/skills/kit-gc/SKILL.md +19 -0
- package/skills/kit-next/SKILL.md +5 -0
- package/skills/kit-status/SKILL.md +92 -0
- package/skills/kit-task-start/SKILL.md +7 -1
- package/templates/rules/branch-naming.md +20 -1
- package/templates/rules/communication-style.md +8 -0
- package/templates/rules/delegation-brief.md +38 -4
- package/templates/rules/effort-model.md +47 -4
- package/templates/rules/naming-and-ids.md +199 -0
- package/templates/rules/task-management.md +1 -1
- package/templates/skills/concrete/SKILL.md +117 -0
- package/templates/skills/karpathy-guidelines/SKILL.md +1 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Network-free: covers cap_checks_summary / cap_classify / cap_action and the branch parser only
|
|
4
4
|
# (the gh-driven captain_gate/pass/loop are not exercised).
|
|
5
5
|
# Run: bash scripts/lib/captain-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
6
7
|
|
|
7
8
|
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
8
9
|
|
|
@@ -31,6 +32,31 @@ if [ -n "${CAP_TEST_INNER:-}" ]; then
|
|
|
31
32
|
# failing checks must not be hidden even when mergeable says MERGEABLE.
|
|
32
33
|
eq "fail beats mergeable" "$(cap_classify MERGEABLE CLEAN FAIL)" "CHECKS_FAILING"
|
|
33
34
|
|
|
35
|
+
# cap_classify + KIT_CAPTAIN_REQUIRE_CHECKS — an EMPTY rollup (NONE) is an ABSENCE of evidence, not
|
|
36
|
+
# a pass. Default OFF, so the four cases below are the whole contract.
|
|
37
|
+
#
|
|
38
|
+
# 1. OFF (unset AND explicit 0) — behaviour is UNCHANGED. This is the regression assertion: an
|
|
39
|
+
# empty rollup still reads CLEAN, exactly as before, so no existing repo's captain moves.
|
|
40
|
+
eq "require unset: NONE still CLEAN" "$(KIT_CAPTAIN_REQUIRE_CHECKS= cap_classify MERGEABLE CLEAN NONE)" "CLEAN"
|
|
41
|
+
eq "require 0: NONE still CLEAN" "$(KIT_CAPTAIN_REQUIRE_CHECKS=0 cap_classify MERGEABLE CLEAN NONE)" "CLEAN"
|
|
42
|
+
eq "require 0: unstable NONE CLEAN" "$(KIT_CAPTAIN_REQUIRE_CHECKS=0 cap_classify MERGEABLE UNSTABLE NONE)" "CLEAN"
|
|
43
|
+
# 2. ON — the empty rollup gets its own verdict, distinct from FAILING and PENDING.
|
|
44
|
+
eq "require 1: NONE is missing" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify MERGEABLE CLEAN NONE)" "CHECKS_MISSING"
|
|
45
|
+
eq "require true: NONE is missing" "$(KIT_CAPTAIN_REQUIRE_CHECKS=true cap_classify MERGEABLE CLEAN NONE)" "CHECKS_MISSING"
|
|
46
|
+
eq "require 1: unstable NONE missing" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify MERGEABLE UNSTABLE NONE)" "CHECKS_MISSING"
|
|
47
|
+
# 3. A real rollup is untouched either way — the setting only speaks about the empty case.
|
|
48
|
+
eq "require 1: PASS still CLEAN" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify MERGEABLE CLEAN PASS)" "CLEAN"
|
|
49
|
+
eq "require 1: FAIL unaffected" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify MERGEABLE UNSTABLE FAIL)" "CHECKS_FAILING"
|
|
50
|
+
eq "require 1: PENDING unaffected" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify MERGEABLE UNSTABLE PENDING)" "CHECKS_PENDING"
|
|
51
|
+
eq "require 0: FAIL unaffected" "$(KIT_CAPTAIN_REQUIRE_CHECKS=0 cap_classify MERGEABLE UNSTABLE FAIL)" "CHECKS_FAILING"
|
|
52
|
+
eq "require 0: PENDING unaffected" "$(KIT_CAPTAIN_REQUIRE_CHECKS=0 cap_classify MERGEABLE UNSTABLE PENDING)" "CHECKS_PENDING"
|
|
53
|
+
# 4. Only the would-be-CLEAN verdict can change — draft/conflict/blocked keep their own answers
|
|
54
|
+
# even with the requirement on, so the rest of the vocabulary provably does not move.
|
|
55
|
+
eq "require 1: draft still draft" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify MERGEABLE DRAFT NONE)" "DRAFT"
|
|
56
|
+
eq "require 1: conflict still conf" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify CONFLICTING BLOCKED NONE)" "CONFLICTING"
|
|
57
|
+
eq "require 1: dirty still conflict" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify UNKNOWN DIRTY NONE)" "CONFLICTING"
|
|
58
|
+
eq "require 1: blocked still blocked" "$(KIT_CAPTAIN_REQUIRE_CHECKS=1 cap_classify UNKNOWN BLOCKED NONE)" "BLOCKED"
|
|
59
|
+
|
|
34
60
|
# cap_action — verdict -> action.
|
|
35
61
|
eq "act clean" "$(cap_action CLEAN)" "merge"
|
|
36
62
|
eq "act conflicting" "$(cap_action CONFLICTING)" "rebase"
|
|
@@ -39,6 +65,8 @@ if [ -n "${CAP_TEST_INNER:-}" ]; then
|
|
|
39
65
|
eq "act draft" "$(cap_action DRAFT)" "wait"
|
|
40
66
|
eq "act held" "$(cap_action HELD)" "hold"
|
|
41
67
|
eq "act blocked" "$(cap_action BLOCKED)" "skip"
|
|
68
|
+
# the whole point: an unobserved gate must never resolve to merge.
|
|
69
|
+
eq "act missing" "$(cap_action CHECKS_MISSING)" "verify"
|
|
42
70
|
|
|
43
71
|
# cap_policy_floor — floors that block an unattended auto-merge (default ON). Non-empty = held.
|
|
44
72
|
nl="$(printf '\n')"
|
|
@@ -57,6 +85,40 @@ if [ -n "${CAP_TEST_INNER:-}" ]; then
|
|
|
57
85
|
# a disabling override lets even a workflow file through (config/CLI can opt out).
|
|
58
86
|
eq "floor: KIT_CAPTAIN_FLOORS=0 disables" "$(KIT_CAPTAIN_FLOORS=0 cap_policy_floor ".github/workflows/ci.yml" "hold")" ""
|
|
59
87
|
|
|
88
|
+
# _cap_load_policy_config — the config bridge for requireChecks, and ENV WINNING over config
|
|
89
|
+
# (same rule as KIT_CAPTAIN_FLOORS). Subshelled so the exports never leak into later assertions.
|
|
90
|
+
if command -v jq >/dev/null 2>&1; then
|
|
91
|
+
bridge() {
|
|
92
|
+
( KIT_CONFIG="$1"; KIT_CAPTAIN_REQUIRE_CHECKS="$2"
|
|
93
|
+
KIT_CAPTAIN_FLOORS=; KIT_CAPTAIN_EXTRA_GLOBS=
|
|
94
|
+
_cap_load_policy_config
|
|
95
|
+
printf '%s' "${KIT_CAPTAIN_REQUIRE_CHECKS:-unset}" )
|
|
96
|
+
}
|
|
97
|
+
cfgon="$(mktemp)"; printf '{"captain":{"mergePolicy":{"requireChecks":true}}}' > "$cfgon"
|
|
98
|
+
cfgoff="$(mktemp)"; printf '{"captain":{"mergePolicy":{"requireChecks":false}}}' > "$cfgoff"
|
|
99
|
+
cfgnone="$(mktemp)"; printf '{"project":{"name":"x"}}' > "$cfgnone"
|
|
100
|
+
eq "bridge: config true -> 1" "$(bridge "$cfgon" "")" "1"
|
|
101
|
+
eq "bridge: config false -> 0" "$(bridge "$cfgoff" "")" "0"
|
|
102
|
+
eq "bridge: key absent -> unset" "$(bridge "$cfgnone" "")" "unset"
|
|
103
|
+
eq "bridge: env 0 beats config" "$(bridge "$cfgon" "0")" "0"
|
|
104
|
+
eq "bridge: env 1 beats config" "$(bridge "$cfgoff" "1")" "1"
|
|
105
|
+
rm -f "$cfgon" "$cfgoff" "$cfgnone"
|
|
106
|
+
|
|
107
|
+
# _cap_cfg_bool must distinguish "set to false" from "not set". jq's `//` does NOT — it treats a
|
|
108
|
+
# literal false as absent — which is why `captain.mergePolicy.floors:false` was documented but
|
|
109
|
+
# inert until this helper replaced it. Locking that here so the opt-out cannot silently rot again.
|
|
110
|
+
cfgf="$(mktemp)"; printf '{"captain":{"mergePolicy":{"floors":false}}}' > "$cfgf"
|
|
111
|
+
eq "cfg_bool: false is not absent" "$(_cap_cfg_bool "$cfgf" floors)" "false"
|
|
112
|
+
eq "cfg_bool: absent is empty" "$(_cap_cfg_bool "$cfgf" requireChecks)" ""
|
|
113
|
+
floorbridge() {
|
|
114
|
+
( KIT_CONFIG="$1"; KIT_CAPTAIN_FLOORS="$2"; KIT_CAPTAIN_EXTRA_GLOBS=; KIT_CAPTAIN_REQUIRE_CHECKS=
|
|
115
|
+
_cap_load_policy_config; printf '%s' "${KIT_CAPTAIN_FLOORS:-unset}" )
|
|
116
|
+
}
|
|
117
|
+
eq "bridge: floors:false -> 0" "$(floorbridge "$cfgf" "")" "0"
|
|
118
|
+
eq "bridge: env 1 beats floors cfg" "$(floorbridge "$cfgf" "1")" "1"
|
|
119
|
+
rm -f "$cfgf"
|
|
120
|
+
fi
|
|
121
|
+
|
|
60
122
|
# _cap_issue_of_branch — pull the issue number out of a flow branch.
|
|
61
123
|
eq "branch task" "$(_cap_issue_of_branch 'task/47-admin-clerk')" "47"
|
|
62
124
|
eq "branch fix" "$(_cap_issue_of_branch 'fix/9-roadmap')" "9"
|
package/scripts/lib/captain.sh
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
# next unblocked wave, and checkpoint so the loop can stop and resume (Effort 75 · #77).
|
|
4
4
|
#
|
|
5
5
|
# Autopilot has two halves. `orchestrate`/`autopilot` LAUNCH the per-issue flows; the captain CLOSES
|
|
6
|
-
# them — it inspects each PR, decides (CLEAN / CONFLICTING / CHECKS_FAILING / CHECKS_PENDING /
|
|
7
|
-
# BLOCKED), merges what is ready, and lets the freshly-merged issues unblock
|
|
8
|
-
# the half that used to be left to the driving agent; now it is a script the
|
|
9
|
-
# runs in a loop.
|
|
6
|
+
# them — it inspects each PR, decides (CLEAN / CONFLICTING / CHECKS_FAILING / CHECKS_PENDING /
|
|
7
|
+
# CHECKS_MISSING / DRAFT / BLOCKED), merges what is ready, and lets the freshly-merged issues unblock
|
|
8
|
+
# the next wave. This is the half that used to be left to the driving agent; now it is a script the
|
|
9
|
+
# agent (or `cckit watch`) runs in a loop.
|
|
10
10
|
#
|
|
11
11
|
# cckit watch one pass: gate every open PR, report (no merge) — safe default
|
|
12
12
|
# cckit watch --merge gate + squash-merge the CLEAN PRs, then show the next wave
|
|
@@ -16,8 +16,28 @@
|
|
|
16
16
|
#
|
|
17
17
|
# Gate decision is three pure helpers (cap_checks_summary / cap_classify / cap_action) so the policy
|
|
18
18
|
# is unit-tested without the network. Requires gh + jq. bash 3.2 / zsh compatible.
|
|
19
|
+
# errors: mixed — cap_* are pure; captain_gate/captain_pass propagate a gh failure
|
|
19
20
|
|
|
20
21
|
CAPTAIN_REPO="${CAPTAIN_REPO:-${KIT_REPO:-}}"
|
|
22
|
+
|
|
23
|
+
# State lives in the shared .cckit/ (kit-state.sh), never CWD-relative: the captain gates the whole
|
|
24
|
+
# repo, so its record must be the same file from the primary checkout and from every worktree.
|
|
25
|
+
# Locate the sibling portably — BASH_SOURCE is bash-only and empty in zsh (#313).
|
|
26
|
+
if [ -n "${BASH_SOURCE:-}" ]; then
|
|
27
|
+
_cap_self="$BASH_SOURCE"
|
|
28
|
+
elif [ -n "${ZSH_VERSION:-}" ]; then
|
|
29
|
+
eval '_cap_self="${(%):-%x}"'
|
|
30
|
+
else
|
|
31
|
+
_cap_self="$0"
|
|
32
|
+
fi
|
|
33
|
+
if [ -f "$(dirname "$_cap_self")/kit-state.sh" ]; then
|
|
34
|
+
# shellcheck source=kit-state.sh
|
|
35
|
+
. "$(dirname "$_cap_self")/kit-state.sh"
|
|
36
|
+
fi
|
|
37
|
+
unset _cap_self
|
|
38
|
+
if [ -z "${CAPTAIN_STATE:-}" ] && command -v kit_state_file >/dev/null 2>&1; then
|
|
39
|
+
CAPTAIN_STATE="$(kit_state_file captain.state)"
|
|
40
|
+
fi
|
|
21
41
|
CAPTAIN_STATE="${CAPTAIN_STATE:-.cckit/captain.state}"
|
|
22
42
|
|
|
23
43
|
# cap_checks_summary — collapse a gh statusCheckRollup JSON array (stdin) to one token:
|
|
@@ -35,8 +55,22 @@ cap_checks_summary() {
|
|
|
35
55
|
|
|
36
56
|
# cap_classify <mergeable> <mergeStateStatus> <checksSummary> — pure verdict for one PR.
|
|
37
57
|
# mergeable: MERGEABLE|CONFLICTING|UNKNOWN · mss: CLEAN|DIRTY|DRAFT|BLOCKED|BEHIND|UNSTABLE|…
|
|
58
|
+
#
|
|
59
|
+
# CHECKS_MISSING — "the exit criteria could not be observed". An EMPTY statusCheckRollup collapses to
|
|
60
|
+
# NONE, and NONE is not a pass: it is the ABSENCE of evidence. Read as green it means a repo with no
|
|
61
|
+
# CI is auto-mergeable by construction, which is how an unattended captain lands a change nothing
|
|
62
|
+
# ever verified. When evidence is REQUIRED (KIT_CAPTAIN_REQUIRE_CHECKS=1, or
|
|
63
|
+
# captain.mergePolicy.requireChecks:true in the kit config — env wins) that case becomes its own
|
|
64
|
+
# verdict, distinct from CHECKS_FAILING (something ran and went red) and CHECKS_PENDING (something is
|
|
65
|
+
# still running), and its action is `verify`, never `merge`.
|
|
66
|
+
#
|
|
67
|
+
# DEFAULT OFF. Requiring evidence in every repo would turn a legitimate no-CI, human-reviewed
|
|
68
|
+
# workflow into a captain that silently merges nothing and reports steady state, so the default keeps
|
|
69
|
+
# today's behaviour and `captain_pass` instead PRINTS the assumption it is making (see the "green was
|
|
70
|
+
# assumed" advisory) with the key that closes it. The narrow guard below is deliberate: only the
|
|
71
|
+
# verdict that would have been CLEAN can change, so nothing else in the vocabulary moves.
|
|
38
72
|
cap_classify() {
|
|
39
|
-
local mergeable="$1" mss="$2" checks="$3"
|
|
73
|
+
local mergeable="$1" mss="$2" checks="$3" require
|
|
40
74
|
case "$mss" in DRAFT) echo DRAFT; return 0 ;; esac
|
|
41
75
|
case "$mergeable" in CONFLICTING) echo CONFLICTING; return 0 ;; esac
|
|
42
76
|
case "$mss" in DIRTY) echo CONFLICTING; return 0 ;; esac
|
|
@@ -44,22 +78,32 @@ cap_classify() {
|
|
|
44
78
|
FAIL) echo CHECKS_FAILING; return 0 ;;
|
|
45
79
|
PENDING) echo CHECKS_PENDING; return 0 ;;
|
|
46
80
|
esac
|
|
81
|
+
# Literal case patterns only (a variable in a case pattern matches literally under zsh).
|
|
82
|
+
case "${KIT_CAPTAIN_REQUIRE_CHECKS:-0}" in 1|true|yes|on) require=1 ;; *) require=0 ;; esac
|
|
47
83
|
case "$mergeable" in
|
|
48
84
|
MERGEABLE)
|
|
49
85
|
# passing or no required checks, and not draft/dirty/conflicting -> ready.
|
|
50
|
-
case "$mss" in
|
|
86
|
+
case "$mss" in
|
|
87
|
+
CLEAN|UNSTABLE|HAS_HOOKS|"")
|
|
88
|
+
if [ "$require" = "1" ] && [ "$checks" = "NONE" ]; then echo CHECKS_MISSING; return 0; fi
|
|
89
|
+
echo CLEAN; return 0 ;;
|
|
90
|
+
esac
|
|
51
91
|
echo BLOCKED; return 0 ;;
|
|
52
92
|
esac
|
|
53
93
|
echo BLOCKED
|
|
54
94
|
}
|
|
55
95
|
|
|
56
96
|
# cap_action <state> — the action the captain takes for a verdict.
|
|
97
|
+
# CHECKS_MISSING -> `verify`, not `wait` (nothing is coming — no check exists to finish) and not
|
|
98
|
+
# `hold` (that is the policy-floor action, reported as "policy floor: <reason>"). Someone must go
|
|
99
|
+
# produce or point at the evidence.
|
|
57
100
|
cap_action() {
|
|
58
101
|
case "$1" in
|
|
59
102
|
CLEAN) echo merge ;;
|
|
60
103
|
CONFLICTING) echo rebase ;;
|
|
61
104
|
CHECKS_FAILING) echo fix ;;
|
|
62
105
|
CHECKS_PENDING) echo wait ;;
|
|
106
|
+
CHECKS_MISSING) echo verify ;;
|
|
63
107
|
DRAFT) echo wait ;;
|
|
64
108
|
HELD) echo hold ;;
|
|
65
109
|
*) echo skip ;;
|
|
@@ -77,6 +121,12 @@ cap_action() {
|
|
|
77
121
|
# Disable entirely with KIT_CAPTAIN_FLOORS=0 (or captain.mergePolicy.floors:false in config). Extend
|
|
78
122
|
# the protected set with KIT_CAPTAIN_EXTRA_GLOBS (space-separated case-globs). Draft state is honored
|
|
79
123
|
# separately by cap_classify (DRAFT -> wait). Pure — no gh; unit-tested. bash 3.2 / zsh safe.
|
|
124
|
+
#
|
|
125
|
+
# A floor is about WHAT THE PR TOUCHES, so it needs the file list and labels and it downgrades a
|
|
126
|
+
# would-be merge to HELD. Missing check evidence is about WHAT IS KNOWN about the PR — decidable from
|
|
127
|
+
# the rollup token alone — so it is a cap_classify verdict (CHECKS_MISSING) instead. Keeping them
|
|
128
|
+
# apart keeps both reasons legible: "a human must sign off on this path" is not the same finding as
|
|
129
|
+
# "nothing ever verified this", and HELD's report line names a floor that would not exist.
|
|
80
130
|
cap_policy_floor() {
|
|
81
131
|
local files="$1" labels="$2" f g extra hit
|
|
82
132
|
[ "${KIT_CAPTAIN_FLOORS:-1}" = "0" ] && return 0
|
|
@@ -117,23 +167,40 @@ EOF
|
|
|
117
167
|
return 0
|
|
118
168
|
}
|
|
119
169
|
|
|
170
|
+
# _cap_cfg_bool <cfg> <key> — echo "true"/"false" for captain.mergePolicy.<key>, or NOTHING when the
|
|
171
|
+
# key is absent. Deliberately NOT `// empty`: jq's `//` treats a literal `false` as absent, so
|
|
172
|
+
# `.foo // empty` silently swallows an explicit opt-out — which is exactly how
|
|
173
|
+
# `captain.mergePolicy.floors:false` came to be documented but inert. `has()` distinguishes
|
|
174
|
+
# "set to false" from "not set", which is the whole distinction a tri-state override needs.
|
|
175
|
+
_cap_cfg_bool() {
|
|
176
|
+
jq -r --arg k "$2" '
|
|
177
|
+
.captain.mergePolicy
|
|
178
|
+
| if type == "object" and has($k) and (.[$k] | type == "boolean")
|
|
179
|
+
then (.[$k] | tostring) else empty end' "$1" 2>/dev/null
|
|
180
|
+
}
|
|
181
|
+
|
|
120
182
|
# _cap_load_policy_config — bridge captain.mergePolicy from the kit config into the env the pure
|
|
121
|
-
#
|
|
122
|
-
#
|
|
183
|
+
# helpers read, so a project can set the merge policy declaratively. Env always wins (a value already
|
|
184
|
+
# set is left untouched). Best-effort: no config / no jq -> defaults (floors ON, requireChecks OFF).
|
|
123
185
|
_cap_load_policy_config() {
|
|
124
186
|
command -v jq >/dev/null 2>&1 || return 0
|
|
125
187
|
local cfg="${KIT_CONFIG:-}"
|
|
126
188
|
[ -n "$cfg" ] || { [ -f cckit.config.json ] && cfg=cckit.config.json || cfg=.claude/kit.config.json; }
|
|
127
189
|
[ -f "$cfg" ] || return 0
|
|
128
190
|
if [ -z "${KIT_CAPTAIN_FLOORS:-}" ]; then
|
|
129
|
-
case "$(
|
|
191
|
+
case "$(_cap_cfg_bool "$cfg" floors)" in
|
|
130
192
|
false) KIT_CAPTAIN_FLOORS=0 ;; true) KIT_CAPTAIN_FLOORS=1 ;;
|
|
131
193
|
esac
|
|
132
194
|
fi
|
|
133
195
|
if [ -z "${KIT_CAPTAIN_EXTRA_GLOBS:-}" ]; then
|
|
134
196
|
KIT_CAPTAIN_EXTRA_GLOBS="$(jq -r '(.captain.mergePolicy.protectedGlobs // []) | join(" ")' "$cfg" 2>/dev/null || echo "")"
|
|
135
197
|
fi
|
|
136
|
-
|
|
198
|
+
if [ -z "${KIT_CAPTAIN_REQUIRE_CHECKS:-}" ]; then
|
|
199
|
+
case "$(_cap_cfg_bool "$cfg" requireChecks)" in
|
|
200
|
+
true) KIT_CAPTAIN_REQUIRE_CHECKS=1 ;; false) KIT_CAPTAIN_REQUIRE_CHECKS=0 ;;
|
|
201
|
+
esac
|
|
202
|
+
fi
|
|
203
|
+
export KIT_CAPTAIN_FLOORS KIT_CAPTAIN_EXTRA_GLOBS KIT_CAPTAIN_REQUIRE_CHECKS
|
|
137
204
|
}
|
|
138
205
|
|
|
139
206
|
# _cap_issue_of_branch <branch> — issue number a flow branch encodes (task/47-x, fix/9-y, effort/12-z).
|
|
@@ -142,9 +209,10 @@ _cap_issue_of_branch() {
|
|
|
142
209
|
}
|
|
143
210
|
|
|
144
211
|
# captain_gate <pr#> — fetch + classify one PR. Echoes
|
|
145
|
-
# "pr<TAB>issue<TAB>state<TAB>action<TAB>title<TAB>reason". A CLEAN PR that trips a policy
|
|
146
|
-
# (cap_policy_floor) is downgraded to HELD/hold so the captain never auto-merges it; `reason`
|
|
147
|
-
# the floor that tripped (empty otherwise).
|
|
212
|
+
# "pr<TAB>issue<TAB>state<TAB>action<TAB>title<TAB>reason<TAB>checks". A CLEAN PR that trips a policy
|
|
213
|
+
# floor (cap_policy_floor) is downgraded to HELD/hold so the captain never auto-merges it; `reason`
|
|
214
|
+
# carries the floor that tripped (empty otherwise). `checks` is the raw rollup token (FAIL/PENDING/
|
|
215
|
+
# PASS/NONE) — REPORTED, not re-decided, so captain_pass can say when a merge rests on NONE.
|
|
148
216
|
captain_gate() {
|
|
149
217
|
local repo="$CAPTAIN_REPO" pr="$1" j mergeable mss checks issue state action title branch files labels reason
|
|
150
218
|
j="$(gh pr view "$pr" --repo "$repo" --json number,title,headRefName,mergeable,mergeStateStatus,statusCheckRollup,files,labels 2>/dev/null)" \
|
|
@@ -165,7 +233,7 @@ captain_gate() {
|
|
|
165
233
|
reason="$(cap_policy_floor "$files" "$labels")"
|
|
166
234
|
[ -n "$reason" ] && { state="HELD"; action="hold"; }
|
|
167
235
|
fi
|
|
168
|
-
printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason"
|
|
236
|
+
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$pr" "${issue:-—}" "$state" "$action" "$title" "$reason" "$checks"
|
|
169
237
|
}
|
|
170
238
|
|
|
171
239
|
# _cap_open_prs [effort] — open PR numbers, optionally only those whose branch-issue is a sub of <effort>.
|
|
@@ -203,11 +271,15 @@ captain_pass() {
|
|
|
203
271
|
CAPTAIN_MERGED=0
|
|
204
272
|
_cap_load_policy_config # bridge captain.mergePolicy from config into the floor env (env wins)
|
|
205
273
|
|
|
206
|
-
local prs pr row state action issue title reason merged_any=0
|
|
274
|
+
local prs pr row state action issue title reason checks merged_any=0 unproven=0
|
|
207
275
|
prs="$(_cap_open_prs "$effort")"
|
|
208
276
|
[ -n "$prs" ] || { echo "captain: no open PRs in scope"; return 0; }
|
|
209
277
|
|
|
210
|
-
: > "$
|
|
278
|
+
# The braces matter: redirections are processed left to right, so `: > "$f" 2>/dev/null` attempts
|
|
279
|
+
# the redirect BEFORE the suppression applies and the shell reports the failure anyway. Wrapping
|
|
280
|
+
# the whole group is what actually silences it. Ensure the dir first so it normally succeeds.
|
|
281
|
+
command -v kit_state_ensure >/dev/null 2>&1 && kit_state_ensure || true
|
|
282
|
+
{ : > "$CAPTAIN_STATE"; } 2>/dev/null || true
|
|
211
283
|
echo "captain: gating $(printf '%s\n' "$prs" | grep -c .) open PR(s)$( [ -n "$effort" ] && echo " for effort #$effort")"
|
|
212
284
|
for pr in $prs; do
|
|
213
285
|
row="$(captain_gate "$pr")" || continue
|
|
@@ -216,7 +288,11 @@ captain_pass() {
|
|
|
216
288
|
issue="$(printf '%s' "$row" | cut -f2)"
|
|
217
289
|
title="$(printf '%s' "$row" | cut -f5)"
|
|
218
290
|
reason="$(printf '%s' "$row" | cut -f6)"
|
|
219
|
-
printf '%s
|
|
291
|
+
checks="$(printf '%s' "$row" | cut -f7)"
|
|
292
|
+
{ printf '%s\t%s\n' "$pr" "$state" >> "$CAPTAIN_STATE"; } 2>/dev/null || true
|
|
293
|
+
# A merge resting on an EMPTY rollup: green was assumed, never observed. Counted here and named
|
|
294
|
+
# once at the end of the pass, so the assumption is on screen even with the requirement OFF.
|
|
295
|
+
if [ "$action" = "merge" ] && [ "$checks" = "NONE" ]; then unproven=$((unproven + 1)); fi
|
|
220
296
|
if [ "$action" = "merge" ] && [ "$do_merge" = "1" ] && [ "$dry" = "0" ]; then
|
|
221
297
|
if gh pr merge "$pr" --repo "$repo" --squash --delete-branch >/dev/null 2>&1; then
|
|
222
298
|
printf ' PR #%-4s %-14s MERGED (#%s %s)\n' "$pr" "$state" "$issue" "$title"
|
|
@@ -233,6 +309,18 @@ captain_pass() {
|
|
|
233
309
|
done
|
|
234
310
|
CAPTAIN_MERGED="$merged_any"
|
|
235
311
|
|
|
312
|
+
# Say the assumption out loud. `requireChecks` is default-off, so this advisory is what keeps it
|
|
313
|
+
# from being a safety feature nobody knows about: it fires at exactly the moment the risk is real
|
|
314
|
+
# (a PR the captain will merge whose rollup was EMPTY), names the key that closes it, and
|
|
315
|
+
# self-silences once the key is on — those PRs then read CHECKS_MISSING, so `unproven` stays 0.
|
|
316
|
+
if [ "$unproven" -gt 0 ]; then
|
|
317
|
+
printf 'captain: %s PR(s) read CLEAN with NO checks observed (empty rollup) — %s\n' \
|
|
318
|
+
"$unproven" "green was ASSUMED, not proved."
|
|
319
|
+
printf ' require evidence instead: captain.mergePolicy.requireChecks:true in your kit\n'
|
|
320
|
+
printf ' config (or KIT_CAPTAIN_REQUIRE_CHECKS=1). Those PRs then read CHECKS_MISSING\n'
|
|
321
|
+
printf ' -> verify, and the captain will not merge them.\n'
|
|
322
|
+
fi
|
|
323
|
+
|
|
236
324
|
# advance: after merges, the newly-unblocked work shows up as the next wave.
|
|
237
325
|
if [ "$merged_any" -gt 0 ]; then
|
|
238
326
|
echo "captain: merged $merged_any — next unblocked wave:"
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# When CCKIT_OUTPUT=json (set by the --llm / --output=json flag), verbs emit a single JSON
|
|
4
4
|
# object on stdout so any agent can parse the result; otherwise they print human-readable text.
|
|
5
5
|
# Dependency-light: jq when present (correct escaping), a pure-bash fallback otherwise.
|
|
6
|
+
# errors: pure — jq when present, pure-bash fallback; cannot fail
|
|
6
7
|
|
|
7
8
|
# cckit_is_json - true when the caller asked for machine-readable output.
|
|
8
9
|
cckit_is_json() { [ "${CCKIT_OUTPUT:-human}" = "json" ]; }
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# scripts/lib/version-bump.sh acts on (feat -> minor; fix/perf/refactor/revert -> patch;
|
|
15
15
|
# feat!/BREAKING CHANGE -> major; the rest -> no release). Keeping the two in step means a title
|
|
16
16
|
# that passes here is one release-please can always classify.
|
|
17
|
+
# errors: strict — a validator: rc 1 on an invalid subject
|
|
17
18
|
|
|
18
19
|
# Conventional Commit subject: type(scope)!: description
|
|
19
20
|
# type — one of the known types below
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# config-path-test.sh — covers the ONE shared config-path resolver (#69): kit_config_find (pure walk)
|
|
4
4
|
# and kit_config_path (KIT_CONFIG wins, else walk). Every kit entrypoint discovers the project config
|
|
5
5
|
# through these. Hermetic: throwaway dirs. Run: bash scripts/lib/config-path-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
6
7
|
set -u
|
|
7
8
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
8
9
|
LIB="$ROOT/scripts/lib"
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
# kit_config_find <startdir> walk startdir -> / for a project config; prints path (rc 0) or rc 1.
|
|
11
11
|
# Ignores KIT_CONFIG — a pure "is <dir> under a kit project?" answer.
|
|
12
12
|
# kit_config_path [startdir] KIT_CONFIG wins, else kit_config_find; prints path (rc 0) or rc 1.
|
|
13
|
+
# errors: pure — dependency-free path resolution
|
|
13
14
|
|
|
14
15
|
kit_config_find() {
|
|
15
16
|
local d="${1:-$PWD}"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# copilot-test.sh — self-test for copilot.sh pure helper under bash AND zsh.
|
|
3
3
|
# Network-free: covers the subagent seed composer only (the gh/plan-driven copilot_brief is not
|
|
4
4
|
# exercised). Run: bash scripts/lib/copilot-test.sh
|
|
5
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
5
6
|
|
|
6
7
|
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
7
8
|
|
package/scripts/lib/copilot.sh
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
# cckit wave --llm the fan-out as TOON rows (wave,number,ctx,prompt) for an agent
|
|
14
14
|
#
|
|
15
15
|
# Requires: gh, jq (via the plan machine). bash 3.2 / zsh compatible.
|
|
16
|
+
# errors: strict — refuses to emit a brief without gh + jq
|
|
16
17
|
|
|
17
18
|
COPILOT_REPO="${COPILOT_REPO:-${KIT_REPO:-}}"
|
|
18
19
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
# origin/main on a non-main-based repo (and the KIT_PROJECTS_V2 board guard never fired via the CLI).
|
|
7
7
|
# Static contract test over bin/cckit: extract the branch block, assert load_kit_config comes first.
|
|
8
8
|
# Run: bash scripts/lib/effort-dispatch-test.sh
|
|
9
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
9
10
|
set -u
|
|
10
11
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
11
12
|
BIN="$ROOT/bin/cckit"
|
|
@@ -21,5 +22,14 @@ lib_ln="$(printf '%s\n' "$blk" | grep -n 'source "\$LIB/effort\.sh"' | head -1 |
|
|
|
21
22
|
t "effort) loads the project config" "$([ -n "$cfg_ln" ] && echo yes)" "yes"
|
|
22
23
|
t "config load precedes the effort libs" "$([ -n "$cfg_ln" ] && [ -n "$lib_ln" ] && [ "$cfg_ln" -lt "$lib_ln" ] && echo yes)" "yes"
|
|
23
24
|
|
|
25
|
+
# #243: every effort subcommand the usage header advertises must actually dispatch, `chain` included
|
|
26
|
+
# — a docs/code drift guard (a subcommand documented but not wired falls through to the usage line).
|
|
27
|
+
usage_subs="$(grep -oE '^# cckit effort <[a-z|]+>' "$BIN" | head -1 | sed -E 's/.*<//; s/>//; s/\|/ /g')"
|
|
28
|
+
t "usage header lists the effort subcommands" "$usage_subs" "new chain start pr close plan"
|
|
29
|
+
for s in $usage_subs; do
|
|
30
|
+
t "effort) dispatches '$s'" \
|
|
31
|
+
"$(printf '%s\n' "$blk" | grep -cE "^ ${s}\)" | tr -d ' ')" "1"
|
|
32
|
+
done
|
|
33
|
+
|
|
24
34
|
[ "$fail" -eq 0 ] && echo "ALL OK"
|
|
25
35
|
exit "$fail"
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# explicit EFFORT_FLOWS env var (wins) -> effort.flows[] in the project config -> built-in default.
|
|
6
6
|
# Hermetic: throwaway configs pointed at via KIT_CONFIG (no network, no gh).
|
|
7
7
|
# Run: bash scripts/lib/effort-flows-test.sh
|
|
8
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
8
9
|
set -u
|
|
9
10
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
10
11
|
LIB="$ROOT/scripts/lib"
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# effort's build WINDOW [start,end] — the window recovers sessions logged before the branch field
|
|
6
6
|
# existed or from a detached/worktree checkout. Hermetic: a throwaway repo + a stubbed usage log +
|
|
7
7
|
# stubbed transcripts under a temp HOME. Run: bash scripts/lib/effort-metrics-test.sh
|
|
8
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
8
9
|
set -u
|
|
9
10
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
10
11
|
LIB="$ROOT/scripts/lib"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#
|
|
13
13
|
# Cost = metered API; retroactively $ is computed from current Opus-4.8 list price (no per-call bill
|
|
14
14
|
# access here) → cost_source="list-price". bash 3.2 compatible. Requires: git, jq.
|
|
15
|
+
# errors: best-effort — local telemetry must never break the op it measures
|
|
15
16
|
|
|
16
17
|
# Opus 4.8 list price, USD per 1M tokens (correct as of 2026-06; update when prices change).
|
|
17
18
|
_EM_PRICE_IN=5.00; _EM_PRICE_OUT=25.00; _EM_PRICE_CACHE_READ=0.50; _EM_PRICE_CACHE_WRITE=6.25
|