@jeiemgi/cckit 0.7.1 → 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.
Files changed (82) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +15 -4
  3. package/README.md +25 -3
  4. package/bin/cckit +91 -8
  5. package/cckit.config.json +1 -1
  6. package/kit.config.schema.json +43 -2
  7. package/package.json +1 -1
  8. package/scripts/autopilot-test.sh +68 -0
  9. package/scripts/autopilot.sh +16 -10
  10. package/scripts/check.sh +14 -1
  11. package/scripts/copilot-loop-test.sh +3 -0
  12. package/scripts/guard-raw-git-ops-test.sh +73 -0
  13. package/scripts/init.sh +68 -8
  14. package/scripts/lib/agent-profile-test.sh +151 -0
  15. package/scripts/lib/agent-profile.sh +195 -0
  16. package/scripts/lib/agent-resolve-test.sh +156 -0
  17. package/scripts/lib/agent-resolve.sh +177 -0
  18. package/scripts/lib/branch-owner-test.sh +99 -0
  19. package/scripts/lib/branch-owner.sh +194 -0
  20. package/scripts/lib/captain-test.sh +86 -0
  21. package/scripts/lib/captain.sh +142 -7
  22. package/scripts/lib/contribute-root-test.sh +40 -0
  23. package/scripts/lib/contribute-root.sh +22 -0
  24. package/scripts/lib/effort-metrics.sh +14 -1
  25. package/scripts/lib/effort-ops-test.sh +54 -2
  26. package/scripts/lib/effort-ops.sh +243 -23
  27. package/scripts/lib/effort-parity-test.sh +5 -3
  28. package/scripts/lib/effort-slug.sh +16 -2
  29. package/scripts/lib/effort.sh +49 -15
  30. package/scripts/lib/gh-project.sh +14 -0
  31. package/scripts/lib/gh-rest-test.sh +301 -0
  32. package/scripts/lib/gh-rest.sh +289 -0
  33. package/scripts/lib/hook-refresh-test.sh +65 -0
  34. package/scripts/lib/hook-refresh.sh +62 -0
  35. package/scripts/lib/kit-config.sh +6 -0
  36. package/scripts/lib/kit-gc-test.sh +178 -1
  37. package/scripts/lib/kit-gc.sh +251 -55
  38. package/scripts/lib/kit-task-ops-test.sh +15 -0
  39. package/scripts/lib/kit-task-ops.sh +231 -58
  40. package/scripts/lib/kto-task-close-test.sh +83 -0
  41. package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
  42. package/scripts/lib/kto-task-pr-test.sh +59 -0
  43. package/scripts/lib/orchestration-runtime-test.sh +142 -0
  44. package/scripts/lib/orchestration-runtime.sh +171 -0
  45. package/scripts/lib/review-stage-test.sh +241 -0
  46. package/scripts/lib/review-stage.sh +259 -0
  47. package/scripts/lib/stage-receipt-test.sh +252 -0
  48. package/scripts/lib/stage-receipt.sh +442 -0
  49. package/scripts/lib/test-env-test.sh +25 -0
  50. package/scripts/lib/test-env.sh +33 -0
  51. package/scripts/lib/worker-brief-test.sh +120 -0
  52. package/scripts/lib/worker-brief.sh +185 -0
  53. package/scripts/lib/worktree-issue.sh +14 -0
  54. package/scripts/lib/worktree-ports-test.sh +146 -0
  55. package/scripts/lib/worktree-start.sh +153 -8
  56. package/scripts/lib/zsh-safety-test.sh +67 -0
  57. package/scripts/orchestrate.sh +124 -22
  58. package/scripts/portable-test.sh +22 -1
  59. package/scripts/review-lint-baseline.txt +28 -0
  60. package/scripts/review-lint-test.sh +271 -0
  61. package/scripts/review-lint.sh +259 -0
  62. package/scripts/review-rules.conf +55 -0
  63. package/scripts/setup-labels.sh +21 -1
  64. package/scripts/skill-frontmatter-baseline.txt +24 -0
  65. package/scripts/skill-frontmatter-lint-test.sh +156 -0
  66. package/scripts/skill-frontmatter-lint.sh +182 -0
  67. package/scripts/task-sync.sh +8 -0
  68. package/scripts/test.sh +10 -1
  69. package/skills/kit-autopilot/SKILL.md +13 -1
  70. package/skills/kit-cleanup/SKILL.md +5 -3
  71. package/skills/kit-contribute/SKILL.md +6 -5
  72. package/skills/kit-effort-close/SKILL.md +8 -3
  73. package/skills/kit-effort-pr/SKILL.md +16 -95
  74. package/skills/kit-gc/SKILL.md +15 -10
  75. package/skills/kit-security-sweep/SKILL.md +4 -6
  76. package/skills/kit-ship/SKILL.md +1 -1
  77. package/skills/kit-task-pr/SKILL.md +2 -0
  78. package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
  79. package/templates/rules/branch-naming.md +6 -0
  80. package/templates/rules/effort-model.md +3 -0
  81. package/templates/rules/naming-and-ids.md +4 -1
  82. package/templates/settings/settings.json.tmpl +4 -2
@@ -14,10 +14,14 @@
14
14
  # errors: strict — a test runner: rc 1 on any failed assertion
15
15
  set -u
16
16
  ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
17
+ # Sealed from the caller's KIT_*/CCKIT_*/EFFORT_* (#369): this suite builds its own fixture.
18
+ # shellcheck source=/dev/null
19
+ . "$ROOT/scripts/lib/test-env.sh" && test_env_seal
17
20
  LIB="$ROOT/scripts/lib"
18
21
  fail=0
19
22
  ok() { echo "ok: $1"; }
20
23
  bad() { echo "FAIL: $1"; fail=1; }
24
+ t() { if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 -> got '$2' want '$3'"; fi; }
21
25
 
22
26
  if ! command -v zsh >/dev/null 2>&1; then
23
27
  echo "zsh-safety-test: zsh absent — skipping (dependency-light gate)"
@@ -56,6 +60,21 @@ run_zsh "kit-gc.sh :: kit_gc_analyze" \
56
60
  run_zsh "kit-gc.sh :: sibling worktree-issue.sh actually loads" \
57
61
  "cd '$ROOT'; unset -f wt_protected_reason 2>/dev/null; source scripts/lib/kit-gc.sh; _kit_gc_load_deps >/dev/null 2>&1; command -v wt_protected_reason >/dev/null 2>&1"
58
62
 
63
+ # agent-resolve.sh / stage-receipt.sh / review-stage.sh — the same sibling-load defect as kit-gc
64
+ # above (#346). Both E318 files resolved their lib dir from a bare `${BASH_SOURCE[0]}`, which is
65
+ # empty under zsh: `dirname ""` is ".", so the sources missed and the walk lost ap_profile_validate
66
+ # and kit_state_dir. Nothing sourced them under zsh until the captain did, so it never fired.
67
+ # `unset -f` first for the same reason kit-gc's case does it — a user init that already defined the
68
+ # symbol would pass the case without resolving anything.
69
+ run_zsh "agent-resolve.sh :: sibling agent-profile.sh actually loads" \
70
+ "cd '$ROOT'; unset -f ap_profile_validate 2>/dev/null; source scripts/lib/agent-resolve.sh; command -v ap_profile_validate >/dev/null 2>&1"
71
+
72
+ run_zsh "stage-receipt.sh :: sibling kit-state.sh actually loads" \
73
+ "cd '$ROOT'; unset -f kit_state_dir 2>/dev/null; source scripts/lib/stage-receipt.sh; command -v kit_state_dir >/dev/null 2>&1"
74
+
75
+ run_zsh "review-stage.sh :: loads both of its dependencies" \
76
+ "cd '$ROOT'; unset -f ap_resolve_pr sr_record 2>/dev/null; source scripts/lib/review-stage.sh; command -v ap_resolve_pr >/dev/null 2>&1 && command -v sr_record >/dev/null 2>&1"
77
+
59
78
  # worktree-start.sh — the `path` local in wt_assign_ports (no-op without .worktree.devPorts).
60
79
  run_zsh "worktree-start.sh :: wt_assign_ports" \
61
80
  "cd '$ROOT'; source scripts/lib/worktree-start.sh; wt_assign_ports '$ROOT' 1 '$ROOT' >/dev/null 2>&1"
@@ -64,6 +83,54 @@ run_zsh "worktree-start.sh :: wt_assign_ports" \
64
83
  run_zsh "kit-events.sh :: emit_event" \
65
84
  "cd '$ROOT'; source scripts/lib/kit-events.sh; emit_event test op '{}' >/dev/null 2>&1"
66
85
 
86
+ # effort.sh :: effort_snapshot_subs — the work-record collapse (#339). `for sha in $shas` relied on
87
+ # the shell word-splitting an unquoted expansion. bash splits on IFS; zsh does not, so the loop ran
88
+ # ONCE with every SHA as a single argument, `git rev-parse --short` failed, and the run still printed
89
+ # "✓ snapshotted 1 commit(s)" and exited 0. This is a BEHAVIOURAL case, not a source-and-run one: a
90
+ # collapsed snapshot returns 0, so only counting the output files catches it.
91
+ #
92
+ # Throwaway repo, 3 commits past the base, snapshot under zsh, then assert one .diff and one
93
+ # index.jsonl line per commit. The trace lands under that repo's git-common-dir, so it goes with the
94
+ # tmpdir.
95
+ snap_tmp="$(mktemp -d)"
96
+ (
97
+ cd "$snap_tmp" || exit 1
98
+ git init -q .
99
+ git config user.email t@t && git config user.name t
100
+ echo base > f.txt && git add f.txt && git commit -qm "base"
101
+ git branch -q effortbase
102
+ for n in 1 2 3; do
103
+ echo "$n" >> f.txt && git add f.txt && git commit -qm "feat: step $n [E99.$n] (#10$n)"
104
+ done
105
+ ) >/dev/null 2>&1
106
+
107
+ # `zsh -fc`, not `-ic`: this case reads the function's STDOUT (the trace dir), and an interactive zsh
108
+ # sources the user's rc, which can print shell-integration escapes into it. The cases above only
109
+ # check exit codes, so they can afford `-i`; this one cannot. Word-splitting — what #339 is about —
110
+ # does not depend on interactivity, so `-f` exercises the same behavior.
111
+ snap_out="$(zsh -fc "cd ${snap_tmp}; source ${LIB}/effort.sh; effort_snapshot_subs 99 effortbase" 2>/dev/null)"
112
+ if [ -z "$snap_out" ] || [ ! -d "$snap_out" ]; then
113
+ bad "effort.sh :: effort_snapshot_subs ran under zsh (no trace dir echoed)"
114
+ else
115
+ ndiff="$(ls "$snap_out"/[0-9][0-9]-*.diff 2>/dev/null | wc -l | tr -d ' ')"
116
+ nidx="$(wc -l < "$snap_out/index.jsonl" 2>/dev/null | tr -d ' ')"
117
+ t "effort_snapshot_subs :: one .diff per commit under zsh" "$ndiff" "3"
118
+ t "effort_snapshot_subs :: one index.jsonl line per commit" "$nidx" "3"
119
+ # A `for sha in $shas` collapse names its stub `NN-` — rev-parse --short fails on the joined list.
120
+ if ls "$snap_out"/[0-9][0-9]-.diff >/dev/null 2>&1; then
121
+ bad "effort_snapshot_subs — wrote a short-sha-less NN-.diff stub (the #339 collapse)"
122
+ else
123
+ ok "effort_snapshot_subs — no short-sha-less stub"
124
+ fi
125
+ # index.jsonl must be true JSONL: one parseable record per line, no `jq -s` needed.
126
+ if jq -e . "$snap_out/index.jsonl" >/dev/null 2>&1; then
127
+ ok "effort_snapshot_subs — index.jsonl is line-parseable JSONL"
128
+ else
129
+ bad "effort_snapshot_subs — index.jsonl is not one JSON record per line"
130
+ fi
131
+ fi
132
+ rm -rf "$snap_tmp"
133
+
67
134
  # ── static regression guard: no bare reserved-name local reintroduced ──────────────────────────
68
135
  # Match a `local` declaration listing a bare `path` word, or a bare `g()` function definition. The
69
136
  # fixed files use namespaced names (wtpath / apppath / logpath / _kit_cfg_get); a plain word here
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env bash
2
- # orchestrate.sh - run N issue flows as live tmux panes, each an agent in its own worktree.
2
+ # orchestrate.sh - run N issue flows as live terminal panes, each an agent in its own worktree.
3
3
  #
4
4
  # For each issue: create an isolated worktree + branch off the configured base branch
5
- # (cckit.config.json: github.repo + github.baseBranch), then open a tmux session with one tiled
6
- # pane per flow running the agent command. Branches must be file-disjoint - the flows edit in
7
- # parallel, so disjointness is the caller's responsibility.
5
+ # (cckit.config.json: github.repo + github.baseBranch), then open a tmux session or Herdr workspace
6
+ # with one pane per flow running the agent command. Branches must be file-disjoint - the flows edit
7
+ # in parallel, so disjointness is the caller's responsibility.
8
8
  #
9
9
  # Agent-agnostic: the per-pane command defaults to `claude` but is overridable, so cckit drives any
10
10
  # CLI agent that takes a prompt as its first argument.
11
- # --agent <cmd> / CCKIT_AGENT=<cmd>
11
+ # --agent <cmd> / CCKIT_AGENT=<cmd> the CLI directly (profile-free path)
12
+ # --profile <name> / CCKIT_PROFILE=<name> a declared agent profile: its kind + its argv
13
+ # --runtime <tmux|herdr> / CCKIT_RUNTIME=<runtime>
12
14
  #
13
15
  # Hardening:
14
16
  # --dry-run resolve + print the launch plan; create no worktrees, start no panes
@@ -21,6 +23,7 @@
21
23
  # cckit orchestrate <issueA> <issueB> [<issueC> ...]
22
24
  # cckit orchestrate --dry-run 6 7 8
23
25
  # cckit orchestrate --cap 3 --agent codex 2 3 6 9
26
+ # cckit orchestrate --runtime herdr --agent codex 2 3 6 9
24
27
  # cckit orchestrate --no-seed 6 7 # don't auto-prompt each agent
25
28
  # cckit orchestrate --force 7 # launch even if blocked_by an open issue
26
29
  # cckit orchestrate --session=sweep 1 2 # custom tmux session name
@@ -34,6 +37,10 @@ FORCE=0
34
37
  DETACH=0
35
38
  CAP=4
36
39
  AGENT="${CCKIT_AGENT:-claude}"
40
+ RUNTIME="${CCKIT_RUNTIME:-tmux}"
41
+ PROFILE="${CCKIT_PROFILE:-}"
42
+ AGENT_ARGS_NL=""
43
+ AGENT_EXPLICIT=0
37
44
  ISSUES=()
38
45
 
39
46
  usage() { sed -n '2,28p' "$0" | sed 's/^# \{0,1\}//'; }
@@ -46,8 +53,12 @@ while [ "$#" -gt 0 ]; do
46
53
  --detach) DETACH=1; shift ;;
47
54
  --cap) CAP="$2"; shift 2 ;;
48
55
  --cap=*) CAP="${1#*=}"; shift ;;
49
- --agent) AGENT="$2"; shift 2 ;;
50
- --agent=*) AGENT="${1#*=}"; shift ;;
56
+ --agent) AGENT="$2"; AGENT_EXPLICIT=1; shift 2 ;;
57
+ --agent=*) AGENT="${1#*=}"; AGENT_EXPLICIT=1; shift ;;
58
+ --profile) PROFILE="$2"; shift 2 ;;
59
+ --profile=*) PROFILE="${1#*=}"; shift ;;
60
+ --runtime) RUNTIME="$2"; shift 2 ;;
61
+ --runtime=*) RUNTIME="${1#*=}"; shift ;;
51
62
  --session=*) SESSION="${1#*=}"; shift ;;
52
63
  -h|--help) usage; exit 0 ;;
53
64
  [0-9]*) ISSUES+=("$1"); shift ;;
@@ -56,11 +67,54 @@ while [ "$#" -gt 0 ]; do
56
67
  done
57
68
 
58
69
  [ "${#ISSUES[@]}" -ge 1 ] || { echo "orchestrate: pass at least one issue number" >&2; usage; exit 2; }
59
- case "$CAP" in ''|*[!0-9]*) echo "orchestrate: --cap needs a number (got '$CAP')" >&2; exit 2 ;; esac
70
+ case "$CAP" in ''|*[!0-9]*) echo "orchestrate: --cap needs a positive number (got '$CAP')" >&2; exit 2 ;; esac
71
+ [ "$CAP" -gt 0 ] || { echo "orchestrate: --cap must be greater than zero" >&2; exit 2; }
60
72
 
61
73
  # Resolve the main worktree root + load config (repo + base branch drive everything).
62
74
  SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
63
75
  ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # cckit INSTALL root — for sourcing libs (works on brew/npm installs)
76
+ # shellcheck source=/dev/null
77
+ source "$ROOT/scripts/lib/orchestration-runtime.sh"
78
+
79
+ # Agent profiles (#320). A profile supplies the agent KIND and its extra argv; cckit never names a
80
+ # model, so whatever model flag the project wants lives in the profile's `args`. Resolution runs
81
+ # BEFORE the preflight so an unknown or stage-barred profile is refused with everything else — no
82
+ # worktree, no pane. `--agent` remains the direct, profile-free path and wins when given.
83
+ if [ "$AGENT_EXPLICIT" -eq 0 ]; then
84
+ # shellcheck source=/dev/null
85
+ source "$ROOT/scripts/lib/config-path.sh" 2>/dev/null || true
86
+ # shellcheck source=/dev/null
87
+ source "$ROOT/scripts/lib/agent-resolve.sh" 2>/dev/null || true
88
+ _oc_cfg=""
89
+ command -v kit_config_path >/dev/null 2>&1 && _oc_cfg="$(kit_config_path 2>/dev/null || true)"
90
+ if [ -n "$_oc_cfg" ] && [ -f "$_oc_cfg" ] && command -v ap_resolve >/dev/null 2>&1; then
91
+ # No issue labels here: this is the run-wide profile. Per-issue `agent:` labels select a
92
+ # profile per entry, which the launch loop cannot express yet (it takes one kind for the run).
93
+ # rc 2 is a REFUSAL (unknown profile, barred stage) and must stop before any worktree. rc 4 is
94
+ # "this project declares no profiles", which is the normal state of every project that has not
95
+ # opted in — it falls through to --agent's default rather than breaking plain orchestration.
96
+ _oc_rc=0
97
+ _oc_prof="$(ap_resolve "$_oc_cfg" build "$PROFILE" '' '')" || _oc_rc=$?
98
+ case "$_oc_rc" in
99
+ 0) : ;;
100
+ 4) if [ -n "$PROFILE" ]; then
101
+ echo "orchestrate: --profile '$PROFILE' given but no agent profiles are declared" >&2; exit 2
102
+ fi
103
+ _oc_prof="" ;;
104
+ *) exit "$_oc_rc" ;;
105
+ esac
106
+ if [ -n "$_oc_prof" ]; then
107
+ AGENT="$(ap_profile_field "$_oc_cfg" "$_oc_prof" kind)"
108
+ AGENT_ARGS_NL="$(ap_profile_args "$_oc_cfg" "$_oc_prof")"
109
+ echo "orchestrate: profile '$_oc_prof' (tier $(ap_profile_tier "$_oc_cfg" "$_oc_prof"), kind $AGENT)"
110
+ fi
111
+ elif [ -n "$PROFILE" ]; then
112
+ echo "orchestrate: --profile '$PROFILE' given but no kit config declares agents.profiles" >&2
113
+ exit 2
114
+ fi
115
+ fi
116
+
117
+ or_runtime_preflight "$RUNTIME" "$AGENT" "$DRYRUN"
64
118
  # The git-repo guard validates the INVOKING project ($PWD), not cckit's install dir; wt_start and
65
119
  # load_kit_config below resolve the project + its config from the invoking directory.
66
120
  git -C "$PWD" rev-parse --show-toplevel >/dev/null 2>&1 || { echo "orchestrate: not in a git repo" >&2; exit 1; }
@@ -71,16 +125,19 @@ REPO="$KIT_REPO"
71
125
  # blocked_by gate: echo the OPEN blocker numbers of an issue (native GitHub dependency edge).
72
126
  open_blockers() {
73
127
  local n="$1" b st blk
74
- blk="$(gh api "repos/$REPO/issues/$n/dependencies/blocked_by" --jq '.[].number' 2>/dev/null || true)"
128
+ blk="$(gh api "repos/$REPO/issues/$n/dependencies/blocked_by" --jq '.[].number')" || {
129
+ echo "orchestrate: could not read blockers for #$n" >&2; return 1;
130
+ }
75
131
  for b in $blk; do
76
132
  st="$(gh issue view "$b" --repo "$REPO" --json state --jq .state 2>/dev/null || echo OPEN)"
77
133
  [ "$st" = "OPEN" ] && printf '%s ' "$b"
78
134
  done
135
+ return 0
79
136
  }
80
137
 
81
138
  # Partition the requested issues into eligible / blocked / (later) queued.
82
139
  ELIGIBLE=()
83
- echo "orchestrate: repo $REPO (base ${KIT_BASE_BRANCH:-main}), cap $CAP, agent '$AGENT'"
140
+ echo "orchestrate: repo $REPO (base ${KIT_BASE_BRANCH:-main}), cap $CAP, runtime '$RUNTIME', agent '$AGENT'"
84
141
  for num in "${ISSUES[@]}"; do
85
142
  blockers="$(open_blockers "$num")"
86
143
  if [ -n "$blockers" ] && [ "$FORCE" -eq 0 ]; then
@@ -108,21 +165,28 @@ if [ "$DRYRUN" -eq 1 ]; then
108
165
  exit 0
109
166
  fi
110
167
 
111
- command -v tmux >/dev/null || { echo "orchestrate: tmux not installed (brew install tmux)" >&2; exit 1; }
112
- command -v "$AGENT" >/dev/null || { echo "orchestrate: agent '$AGENT' not on PATH" >&2; exit 1; }
113
-
114
168
  # shellcheck source=/dev/null
115
169
  source "$ROOT/scripts/lib/worktree-start.sh"
116
170
 
117
171
  # Headless seed: the agent runs with NO human present - it must never ask, decide autonomously,
118
172
  # gauge difficulty + apply proportional effort, and close no-op issues itself. cckit verbs only.
173
+ #
174
+ # The framing and the receipt contract live in worker-brief.sh (#321), not here, because they are
175
+ # the two parts that must survive truncation and a budget is the resolved profile's to set.
176
+ # shellcheck source=/dev/null
177
+ source "$ROOT/scripts/lib/worker-brief.sh"
178
+ SEED_BUDGET=""
179
+ [ -n "${_oc_cfg:-}" ] && [ -n "${_oc_prof:-}" ] && SEED_BUDGET="$(wb_profile_budget "$_oc_cfg" "$_oc_prof")"
180
+
119
181
  seed_for() {
120
- local num="$1" branch="$2"
121
- printf '%s' "You are running HEADLESS inside a cckit orchestration: there is NO human to answer \
122
- questions, so NEVER ask - decide autonomously and proceed. Gauge the task difficulty and apply \
123
- proportional effort. Worktree + branch $branch for issue #$num are ready. Run: gh issue view $num, \
124
- implement it, run bash scripts/check.sh until green, then open the PR with: cckit pr $num \"<summary>\". \
125
- If it is a no-op (nothing to change), comment why and run: cckit close $num \"<reason>\". Do not wait for input."
182
+ local num="$1" branch="$2" wt="${3:-$PWD}" brief
183
+ brief="$(cd "$wt" && "$ROOT/bin/cckit" brief "$num" 2>/dev/null)" || brief=""
184
+ if [ -z "$brief" ]; then
185
+ # Nested single quotes would terminate the format string and make printf recycle it over the
186
+ # stray words as arguments, so the fallback names the command without quoting it.
187
+ brief="$(printf 'The generated cckit brief was unavailable. Read only issue #%s with: gh issue view %s\n' "$num" "$num")"
188
+ fi
189
+ printf '%s\n' "$brief" | wb_compose "$num" "$branch" "$SEED_BUDGET" || true
126
190
  }
127
191
 
128
192
  ENTRIES=()
@@ -131,6 +195,44 @@ for num in "${LAUNCH[@]}"; do
131
195
  ENTRIES+=("$entry")
132
196
  done
133
197
 
198
+ # ── one writer per branch (#323) ────────────────────────────────────────────────────────────────
199
+ # wt_start hands back the branch each flow will push. A second wave launched onto a branch a live
200
+ # worker is already writing is the corruption rules/branch-naming.md describes, and git does not
201
+ # catch it: git refuses one branch in two WORKTREES, which says nothing about two agent processes
202
+ # driving the branch cckit just handed them. Claim the lease before a single pane starts, and
203
+ # release every claim if any one of them is contested — a half-launched wave is worse than none.
204
+ # shellcheck source=/dev/null
205
+ source "$ROOT/scripts/lib/branch-owner.sh"
206
+ BO_OWNER="orchestrate:$SESSION:$$"
207
+ CLAIMED=()
208
+ _bo_release_all() {
209
+ local c
210
+ for c in ${CLAIMED+"${CLAIMED[@]}"}; do bo_release "$c" "$BO_OWNER" >/dev/null 2>&1 || true; done
211
+ }
212
+ for entry in "${ENTRIES[@]}"; do
213
+ rest="${entry#*|}"; branch="${rest%%|*}"; num="${rest##*|}"
214
+ # Empty pid: orchestrate exits while the panes keep writing, so the lease must not be tied to
215
+ # this process. The worktree is the liveness signal (branch-owner.sh explains the argument).
216
+ if ! bo_claim "$branch" "$BO_OWNER" "${entry%%|*}" ""; then
217
+ echo "orchestrate: #$num — another writer already owns $branch; not launching this wave" >&2
218
+ _bo_release_all
219
+ exit 1
220
+ fi
221
+ CLAIMED+=("$branch")
222
+ done
223
+ # The lease outlives this process on purpose: the pane keeps writing after orchestrate returns, and
224
+ # the ledger reclaims it on positive evidence (the worktree is gone, or the pid died on this host).
225
+
226
+ if [ "$RUNTIME" = "herdr" ]; then
227
+ or_herdr_launch "$SESSION" "$AGENT" "$SEED" "$DETACH" "${KIT_PROJECT_SLUG:-project}" "$AGENT_ARGS_NL" "${ENTRIES[@]}"
228
+ exit $?
229
+ fi
230
+
231
+ # The profile's argv on the tmux path. Herdr got it as an argv array above; tmux types a command
232
+ # LINE into the pane's shell, so the quoting lives in or_tmux_agent_cmd beside the Herdr launcher —
233
+ # both runtimes answer the same question and neither may drop the args the resolution line promised.
234
+ AGENT_CMD="$(or_tmux_agent_cmd "$AGENT" "$AGENT_ARGS_NL")"
235
+
134
236
  tmux kill-session -t "$SESSION" 2>/dev/null || true
135
237
  first=1
136
238
  for entry in "${ENTRIES[@]}"; do
@@ -149,11 +251,11 @@ for entry in "${ENTRIES[@]}"; do
149
251
  # parsed by the pane's shell. Double-quoting collided with the seed's own quotes and
150
252
  # dumped `<summary>` onto zsh as a redirection ("no such file or directory: summary"),
151
253
  # so the agent never launched. Escape any single quotes for safe single-quote wrapping.
152
- seed="$(seed_for "$num" "$branch")"
254
+ seed="$(seed_for "$num" "$branch" "$wt")"
153
255
  esc=${seed//\'/\'\\\'\'}
154
- tmux send-keys -t "$pane" "$AGENT '$esc'" C-m
256
+ tmux send-keys -t "$pane" "$AGENT_CMD '$esc'" C-m
155
257
  else
156
- tmux send-keys -t "$pane" "$AGENT" C-m
258
+ tmux send-keys -t "$pane" "$AGENT_CMD" C-m
157
259
  fi
158
260
  done
159
261
  tmux select-layout -t "$SESSION:flows" tiled >/dev/null
@@ -8,6 +8,9 @@
8
8
  # Hermetic: stubs `gh` (no network/auth). Run: bash scripts/portable-test.sh
9
9
  set -u
10
10
  ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11
+ # Sealed from the caller's KIT_*/CCKIT_*/EFFORT_* (#369): this suite builds its own fixture.
12
+ # shellcheck source=/dev/null
13
+ . "$ROOT/scripts/lib/test-env.sh" && test_env_seal
11
14
  CCKIT="$ROOT/bin/cckit"
12
15
  fail=0
13
16
  t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
@@ -91,11 +94,29 @@ yes "gc resolves the invoking repo" "$(cat "$GH_REPO_LOG")" "$FIX_REPO"
91
94
  no "brief never resolves cckit's own repo from a foreign checkout" "$(cat "$GH_REPO_LOG")" "$OWN_REPO"
92
95
  yes "brief resolves the invoking repo" "$(cat "$GH_REPO_LOG")" "$FIX_REPO"
93
96
 
97
+ # `receipt` makes no gh call, so the --repo log cannot judge it — but it WRITES, and writing into
98
+ # cckit's own .cckit/ from someone else's checkout is the same leak in a different resource. The
99
+ # state dir is derived from --git-common-dir, so a foreign repo must get its own.
100
+ if command -v jq >/dev/null 2>&1; then
101
+ ( cd "$fix" && PATH="$stub:$PATH" "$CCKIT" receipt 1 --stage build >/dev/null 2>&1 <<'EOF'
102
+ outcome: pr-open
103
+ url: https://example/1
104
+ gate: pass
105
+ blocker: none
106
+ next stage: review
107
+ EOF
108
+ )
109
+ yes "receipt writes into the INVOKING repo's state dir" \
110
+ "$([ -f "$fix/.cckit/receipts/1-build-1.json" ] && echo yes || echo no)" "yes"
111
+ no "receipt leaves nothing in cckit's own state dir" \
112
+ "$(ls "$ROOT/.cckit/receipts" 2>/dev/null | grep -c '^1-build-1\.json$' || true)" "1"
113
+ fi
114
+
94
115
  # ── BY CONSTRUCTION: every verb in `cckit commands` is classified (exercised or explicitly skipped) ─
95
116
  # A new verb that is neither exercised nor listed here fails the harness — forcing a coverage
96
117
  # decision. SKIP holds verbs that mutate, need args, read stdin, are interactive, or act on the
97
118
  # install itself (not the invoking project's board) — deliberately not driven here.
98
- SKIP="adopt autopilot bench brief close commands completions contribute copilot debug digest effort encode-context handoff help init install migrate msg orchestrate pr release render resume start ui update version watch"
119
+ SKIP="adopt autopilot bench brief close commands completions contribute copilot debug digest effort encode-context handoff help init install merge migrate msg new orchestrate pr receipt release render resume start ui update version watch"
99
120
  classified() { case " $EXERCISE $SKIP " in *" $1 "*) return 0 ;; *) return 1 ;; esac; }
100
121
  for v in $("$CCKIT" commands); do
101
122
  classified "$v" || { echo "FAIL: verb '$v' is unclassified — add it to EXERCISE (read-only, assert no own-repo leak) or SKIP in portable-test.sh"; fail=1; }
@@ -0,0 +1,28 @@
1
+ # review-lint-baseline.txt — generated by scripts/review-lint.sh --update
2
+ # Pre-existing hits, GRANDFATHERED per file: they may stay, but may never grow, and a
3
+ # file not listed here must have zero hits. Fix a file and re-run --update to tighten.
4
+ #
5
+ # <RULE>\t<path>\t<count> (TAB-separated: a path may contain a space)
6
+ refs-word-splitting scripts/lib/effort-ops-test.sh 1
7
+ fence-missing-language .claude/rules/branch-naming.md 1
8
+ fence-missing-language .claude/rules/effort-model.md 1
9
+ fence-missing-language .claude/skills/karpathy-guidelines/SKILL.md 1
10
+ fence-missing-language CONTRIBUTING.md 1
11
+ fence-missing-language README.md 1
12
+ fence-missing-language skills/kit-autopilot/SKILL.md 2
13
+ fence-missing-language skills/kit-dev/SKILL.md 1
14
+ fence-missing-language skills/kit-next/SKILL.md 3
15
+ fence-missing-language skills/kit-plan-next/SKILL.md 2
16
+ fence-missing-language skills/kit-task-sync/SKILL.md 1
17
+ fence-missing-language skills/kit-ux-audit/references/graph-model.md 2
18
+ fence-missing-language skills/kit-ux-audit/references/heuristics.md 1
19
+ fence-missing-language templates/agents/security.md 1
20
+ fence-missing-language templates/agents/ux.md 1
21
+ fence-missing-language templates/rules/branch-naming.md 1
22
+ fence-missing-language templates/rules/effort-model.md 1
23
+ fence-missing-language templates/rules/plan-next.md 1
24
+ fence-missing-language templates/rules/plan-output-format.md 1
25
+ fence-missing-language templates/skills/copywriting/references/copy-frameworks.md 5
26
+ fence-missing-language templates/skills/feature-build-refine/SKILL.md 2
27
+ fence-missing-language templates/skills/karpathy-guidelines/SKILL.md 1
28
+ fence-missing-language templates/skills/speckit/SKILL.md 2