@jeiemgi/cckit 0.3.0 → 0.4.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/README.md CHANGED
@@ -1,30 +1,42 @@
1
1
  <p align="center">
2
- <img src=".github/banner.png" alt="cckit — a project operating system for coding agents" width="100%">
2
+ <img src=".github/banner.png" alt="cckit — you're the architect, cckit runs the mechanics" width="100%">
3
3
  </p>
4
4
 
5
5
  # cckit
6
6
 
7
- > A project operating system for coding agents — the full GitHub work lifecycle as a CLI, drivable by Claude Code and any other agent.
7
+ > **You're the architect. cckit runs the mechanics.** The full GitHub work lifecycle — issues,
8
+ > worktrees, PRs, merges, multi-agent waves — as one CLI, drivable by Claude Code and any agent.
8
9
 
9
10
  [![License: MIT OR Apache-2.0](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue.svg)](#license)
10
11
  [![Built for Claude Code](https://img.shields.io/badge/built%20for-Claude%20Code-8A63D2.svg)](https://docs.claude.com/claude-code)
11
12
  [![Docs](https://img.shields.io/badge/docs-cckit.vercel.app-0A7E8C.svg)](https://cckit.vercel.app)
12
13
  [![Platforms: macOS · Linux · WSL](https://img.shields.io/badge/platforms-macOS%20%C2%B7%20Linux%20%C2%B7%20WSL-555.svg)](#platforms--requirements)
13
14
 
14
- **[📖 Documentation](https://cckit.vercel.app)** · [Tutorials](https://cckit.vercel.app/tutorials/) · [Quick start](#quick-start) · [Contributing](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md)
15
+ **[📖 Documentation](https://cckit.vercel.app)** · [The idea](https://cckit.vercel.app/philosophy/) · [Tutorials](https://cckit.vercel.app/tutorials/) · [Quick start](#quick-start) · [Contributing](CONTRIBUTING.md) · [Code of Conduct](CODE_OF_CONDUCT.md)
15
16
 
16
- cckit turns a Git repository into a structured, agent-operable workspace. It ships the entire
17
- GitHub lifecycle — issues, branches, isolated worktrees, PRs, the merge flow, garbage collection,
18
- and a multi-agent orchestrator — as a single bash CLI plus a Claude Code plugin (skills, rules,
19
- agents). It is **agent-agnostic by design**: Claude Code is first-class, but any agent that can run
20
- a shell can drive every operation.
17
+ The whole idea in one line:
18
+
19
+ > **Turn your Git into retrievable, efficient context** — using issues, GitHub Projects, and other
20
+ > people's tools, wired together with a few advanced mechanics.
21
+
22
+ You bring the ideas and the shape of the thing. The mechanics that make it stand up — branches,
23
+ isolated worktrees, PRs, the merge flow, and the trail of issues that says *why* — are what cckit
24
+ takes care of. It ships all of that as a single bash CLI plus a Claude Code plugin (skills, rules,
25
+ agents), and it is **agent-agnostic by design**: Claude Code is first-class, but any agent that can
26
+ run a shell can drive every operation.
21
27
 
22
28
  ## Why
23
29
 
24
30
  - **One lifecycle, one source of truth.** Start an issue, get an isolated worktree and branch, open
25
- a PR, merge, and clean up — each step is one command, correct by construction.
31
+ a PR, merge, and clean up — each step is one command, correct by construction. The board is both
32
+ the plan and the proof.
33
+ - **Sessions that pick up where you left off.** `cckit handoff "<note>"` saves a resume-here note;
34
+ bare `cckit` prints it at the start of the next session — context survives the context window.
26
35
  - **Agent-operable.** Every verb has a machine-readable mode (`cckit <verb> --llm`) and an
27
36
  [`AGENTS.md`](AGENTS.md) contract, so agents drive the kit without scraping human output.
37
+ - **Scales from one issue to a wave.** The same verbs that take one issue to a merged PR also plan
38
+ and run a whole wave of parallel agents — with a captain that gates and merges behind policy
39
+ floors.
28
40
  - **Zero hard dependencies.** Pure bash with graceful fallbacks; it auto-detects optional tools
29
41
  (`gh`, `jq`, `fzf`, `gum`) and degrades instead of failing.
30
42
  - **Portable.** No company, framework, or repo is baked in — everything is driven from
@@ -70,22 +82,33 @@ Requirements: `bash` 4+, `git`, and `gh` (GitHub CLI) authenticated. `jq` recomm
70
82
  ## Quick start
71
83
 
72
84
  ```bash
73
- cckit init # scaffold cckit.config.json + .claude/ for this repo
74
- cckit plan-next # propose what to build next, grounded in current capabilities
75
- cckit next # the next unblocked issue + how to start it
76
- cckit start 42 # isolated worktree + branch for issue #42
77
- cckit pr 42 "what changed" # commit, push, open the PR
78
- cckit sync # board state, what's unblocked
79
- cckit gc # prune merged branches + worktrees
85
+ cckit doctor # onboarding preflight: deps, gh auth
86
+ cckit init --profile software # scaffold cckit.config.json + .claude/ for this repo
87
+ # profiles: software · content · research · automation · minimal
88
+ cckit plan-next # propose what to build next, grounded in current capabilities
89
+ cckit next # the next unblocked issue + how to start it
90
+ cckit start 42 # isolated worktree + branch for issue #42
91
+ cckit pr 42 "what changed" # commit, push, open the PR
92
+ cckit sync # board state, what's unblocked
93
+ cckit handoff "resume note" # save a handoff — bare `cckit` prints it next session
94
+ cckit gc # prune merged branches + worktrees
80
95
  ```
81
96
 
82
- Run `cckit help` for the full verb list, or `cckit <verb> --help` for any one.
97
+ Adopting cckit in a repo that already has history? `cckit scan` detects the stack, `cckit adopt`
98
+ records kit-shaped files the repo already has, and `cckit status` is the thin dashboard — board,
99
+ worktrees, and the resume handoff in one screen. Run `cckit help` for the full verb list, or
100
+ `cckit <verb> --help` for any one.
83
101
 
84
102
  ## Efforts and slug handles
85
103
 
86
104
  A big piece of work is an **effort** — a parent issue with sub-issues. `cckit effort new "<name>" "sub :: desc" …`
87
105
  creates the parent issue (the four-section plan body), applies the `ctx/kind/priority/role/flow` labels, and lints
88
- every sub-issue title — the same effort `/kit-effort-new` produces, since both call one shared core.
106
+ every sub-issue title — the same effort `/kit-effort-new` produces, since both call one shared core. The `--flow`
107
+ vocabulary (the `[Flow]` title tags) reads from `effort.flows` in the project config, so `cckit effort new --flow X`
108
+ works out of the box in any configured repo (an explicit `EFFORT_FLOWS` env var still wins per invocation).
109
+ `cckit effort close` is likewise the **single close implementation** (the `/kit-effort-close` skill is a thin caller
110
+ of the same function): pre-squash work-record snapshot + metrics, squash-merge, close parent + subs, board
111
+ Status=Done, worktree/branch GC, an optional knowledge-ingest hook, and an advisory kit-sync drift check.
89
112
 
90
113
  The GitHub issue **number** stays the canonical key, but every effort also has a memorable **slug** handle (the one
91
114
  already in its `effort/<N>-<slug>` branch). Effort commands take the slug *or* the number interchangeably:
@@ -101,17 +124,19 @@ A pure-digits argument is always a number; anything else is resolved to the cano
101
124
  matching `effort/*` branches, the `slug:<slug>` label, then open effort titles. An unknown or
102
125
  ambiguous slug fails with a clear error rather than guessing. Efforts render as `slug #N`.
103
126
 
104
- ## Wave
127
+ ## Waves — parallel agentic development
105
128
 
106
129
  `cckit wave` reads your open efforts and proposes the incoming waves of work — parallel agent tasks
107
- that gate and merge themselves:
130
+ that gate and merge themselves. This is the part that turns one keyboard into a small team:
108
131
 
109
132
  ```bash
110
133
  cckit plan # the wave plan: deps-ordered, file-disjoint, session-fit
111
134
  cckit wave # a Task-subagent fan-out brief Claude Code enacts (proposes the next wave)
135
+ cckit orchestrate 12 14 17 # run N flows in parallel worktrees (--dry-run / --cap / --agent)
112
136
  cckit watch --merge # the captain: gate open PRs, squash-merge the CLEAN ones, advance
113
137
  # (policy floors hold PRs touching CI, lockfiles, or secrets for review)
114
138
  cckit watch --loop # self-pace gate/merge passes until steady state
139
+ cckit autopilot # unattended multi-flow: drive (or auto-pick) issues under a cap
115
140
  ```
116
141
 
117
142
  ## Driven by agents
@@ -129,9 +154,23 @@ cckit wave --llm # the fan-out (one subagent prompt per issue) as TOON
129
154
  Human output renders as markdown — rich via `glow` in a terminal, native in the Claude Code
130
155
  transcript, pipe-safe everywhere (`cckit render` exposes the seam for any script).
131
156
 
157
+ ## cckit builds cckit
158
+
159
+ None of this is theoretical. cckit is developed *with* cckit — every feature, fix, and tutorial went
160
+ through its own lifecycle: an issue, an isolated worktree, a pull request, a merge. The receipts are
161
+ public: [every issue closed in the repo →](https://github.com/jeiemgi/cckit/issues?q=is%3Aissue%20state%3Aclosed)
162
+ — including [the effort that produced this README](https://github.com/jeiemgi/cckit/issues/160).
163
+ The board is both the plan and the proof.
164
+
132
165
  ## Documentation
133
166
 
134
- Full docs, the [tutorials](https://cckit.vercel.app/tutorials/) (step-by-step "How to X with Claude Code" guides), the [cookbook](https://cckit.vercel.app/cookbook/) of lifecycle recipes, and the [CLI reference](https://cckit.vercel.app/cli-reference/) live at **[cckit.vercel.app](https://cckit.vercel.app)**.
167
+ Full docs live at **[cckit.vercel.app](https://cckit.vercel.app)** — start with
168
+ [the idea](https://cckit.vercel.app/philosophy/) if you want the why. The
169
+ [tutorials](https://cckit.vercel.app/tutorials/) are step-by-step "How to X with Claude Code"
170
+ guides, each labelled **Beginner / Intermediate / Advanced** and carrying a **"Copy as Markdown"
171
+ prompt** you can paste straight into Claude Code — start exactly where you are. The
172
+ [cookbook](https://cckit.vercel.app/cookbook/) holds lifecycle recipes, and the
173
+ [CLI reference](https://cckit.vercel.app/cli-reference/) covers every verb.
135
174
 
136
175
  ## Project layout
137
176
 
@@ -142,6 +181,7 @@ cckit/
142
181
  .claude-plugin/ # the Claude Code plugin manifest
143
182
  skills/ commands/ # Claude Code skills + slash commands
144
183
  profiles/ templates/ # init profiles + scaffold templates
184
+ routines/ modules/ # scheduled routines + optional modules
145
185
  docs-site/ # documentation source — Astro/Starlight (deployed to cckit.vercel.app)
146
186
  cckit.config.json # project configuration (no hardcoded org/repo)
147
187
  ```
@@ -161,7 +201,8 @@ More variants (HTML, flat-square): [docs/badge.md](docs/badge.md).
161
201
  ## Contributing
162
202
 
163
203
  Issues and PRs welcome — see [`CONTRIBUTING.md`](CONTRIBUTING.md). cckit develops itself with its
164
- own lifecycle (`cckit start` / `cckit pr`).
204
+ own lifecycle (`cckit start` / `cckit pr`), and `cckit contribute "<summary>"` opens a contribution
205
+ PR gated on the repo checks. Be curious, and be kind — that's how the open-source community works.
165
206
 
166
207
  ## Support
167
208
 
package/bin/cckit CHANGED
@@ -102,6 +102,11 @@ case "$cmd" in
102
102
  if cckit_is_json; then cckit_json version "$v"; else echo "cckit $(ui_paint '1;36' "$v")"; fi
103
103
  ;;
104
104
  effort)
105
+ # Load the project config FIRST (like every sibling verb): KIT_REPO / KIT_BASE_BRANCH /
106
+ # KIT_PROJECTS_V2 drive repo resolution, the worktree base, and the board guard below —
107
+ # without this, effort start silently branches from origin/main on a non-main-based repo (#151).
108
+ # shellcheck source=/dev/null
109
+ source "$LIB/kit-config.sh" && load_kit_config
105
110
  # shellcheck source=/dev/null
106
111
  source "$LIB/effort.sh"
107
112
  # shellcheck source=/dev/null
package/cckit.config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "./kit.config.schema.json",
3
- "kitVersion": "0.3.0",
3
+ "kitVersion": "0.4.0",
4
4
  "project": {
5
5
  "name": "cckit",
6
6
  "slug": "cckit",
@@ -105,8 +105,10 @@ _plug="$(jq -r '.version // "0.0.0"' "/Users/josegutierrezdelgado/.claude/plugin
105
105
  "${CLAUDE_PLUGIN_ROOT}/scripts/init.sh" --upgrade --target "$PWD" --dry-run
106
106
  ```
107
107
  Then run it for real to see the precise added/preserved report (step 4). Make clear: upgrade only
108
- **adds** missing files and **merges** new config keys — your existing `.claude/` files and
109
- `kit.config.json` values are never overwritten.
108
+ **adds** missing files and **merges** new required config keys — your existing `.claude/` files
109
+ (including a customized `.claude/statusline.sh` shim) and `kit.config.json` values are never
110
+ overwritten, and feature blocks your config deliberately lacks (`plans`, `specKit`, `prePush`,
111
+ `local`, `memory`) are never injected from profile defaults.
110
112
 
111
113
  4. **Confirm, then apply.** Ask with `AskUserQuestion`: **Apply update** · **Preview only** · **Skip**.
112
114
  Per the CLI-style preference, when the delta is purely additive (only new files, nothing preserved
@@ -122,8 +124,11 @@ _plug="$(jq -r '.version // "0.0.0"' "/Users/josegutierrezdelgado/.claude/plugin
122
124
 
123
125
  ## Rules
124
126
 
125
- - **Never clobber.** Upgrade only ADDS missing files and MERGES new `kit.config.json` keys; existing
126
- files and config values are preserved. Always show the `--dry-run` preview before applying.
127
+ - **Never clobber.** Upgrade only ADDS missing files and MERGES new required `kit.config.json` keys;
128
+ existing files and config values are preserved. A file the kit cannot prove it owns intact — edited
129
+ by the project or absent from the manifest (e.g. a repointed `.claude/statusline.sh`) — is kept, and
130
+ feature blocks the config deliberately lacks are never injected from profile defaults. Always show
131
+ the `--dry-run` preview before applying.
127
132
  - When reporting effective configuration, honor per-folder `.claudekit/config.json` overrides
128
133
  (nearest-wins) — see `scripts/lib/kit-config.sh`.
129
134
  - Don't fabricate changelog content — read `CHANGELOG.md`. If the project predates version tracking
@@ -68,6 +68,7 @@
68
68
  "type": "object",
69
69
  "additionalProperties": true,
70
70
  "properties": {
71
+ "flows": { "type": "array", "items": { "type": "string" }, "description": "Controlled flow vocabulary for effort titles — the values accepted by the leading [Flow] title tag and `--flow` (also the flow:<flow> labels). Replaces the built-in default (Core UI API Docs Infra Auth Data Web App); an explicit EFFORT_FLOWS env var still wins per invocation." },
71
72
  "knowledgeIngestHook": { "type": "string", "description": "Optional path to an executable run after `cckit effort close`, invoked as `<hook> <effort-number> <trace-dir>` to fold the closed effort's work record into a knowledge base. No-op when unset or not executable; the kit ships no default." }
72
73
  }
73
74
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeiemgi/cckit",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "description": "cckit — a project operating system for coding agents (CLI + Claude Code plugin).",
@@ -94,6 +94,40 @@ t "diff is only the kitVersion line" "$only_kitver" "yes"
94
94
  t "kitVersion bumped to plugin version" "$(jq -r '.kitVersion' .claude/kit.config.json)" "$PLUGIN_VERSION"
95
95
  t "upgrade block preserved through merge" "$(jq -r '.upgrade.removed | length' .claude/kit.config.json)" "2"
96
96
 
97
+ # --- #149: upgrade preserves existing project files -------------------------------------
98
+ # 4. feature keys deliberately absent from the config are NOT injected by the merge
99
+ # (the seed config never had plans/specKit/prePush/local/memory — profile defaults must
100
+ # not resurrect them), while REQUIRED structural keys still merge in.
101
+ for k in plans specKit prePush local memory; do
102
+ t "feature key '$k' not injected" "$(jq --arg k "$k" 'has($k)' .claude/kit.config.json)" "false"
103
+ done
104
+ t "required key 'knowledge' still added" "$(jq -r '.knowledge.dir // "absent"' .claude/kit.config.json)" "knowledge"
105
+
106
+ # 5. a CUSTOMIZED statusline shim survives the next upgrade (the v0.3.0 clobber: kit-wire
107
+ # replaced a repointed shim with the template on every upgrade).
108
+ git add -A && git commit -q -m "settle upgrade under test"
109
+ t "statusline shim exists after wire" "$([ -f .claude/statusline.sh ] && echo yes || echo no)" "yes"
110
+ SL_MARKER="# LOCAL-STATUSLINE-EDIT-#149 (must survive upgrade)"
111
+ printf '\n%s\n' "$SL_MARKER" >> .claude/statusline.sh
112
+ jq '.kitVersion = "0.0.2"' .claude/kit.config.json > .claude/kit.config.json.tmp \
113
+ && mv .claude/kit.config.json.tmp .claude/kit.config.json
114
+ git add -A && git commit -q -m "customize statusline + reset version"
115
+
116
+ CLAUDE_PLUGIN_ROOT="$PLUGIN_DIR" bash "$INIT" --upgrade --target "$proj" >/dev/null 2>&1 \
117
+ || { echo "FAIL: statusline upgrade run exited non-zero"; exit 1; }
118
+ t "customized statusline preserved (tracked: modified)" "$(grep -cF "$SL_MARKER" .claude/statusline.sh)" "1"
119
+
120
+ # ...and also when the manifest is absent (fresh clone: shim exists but is UNTRACKED).
121
+ git add -A && git commit -q -m "settle statusline upgrade"
122
+ rm -f .claude/kit.manifest.json
123
+ jq '.kitVersion = "0.0.3"' .claude/kit.config.json > .claude/kit.config.json.tmp \
124
+ && mv .claude/kit.config.json.tmp .claude/kit.config.json
125
+ git add -A && git commit -q -m "reset version (manifest absent)"
126
+ CLAUDE_PLUGIN_ROOT="$PLUGIN_DIR" bash "$INIT" --upgrade --target "$proj" >/dev/null 2>&1 \
127
+ || { echo "FAIL: manifest-absent upgrade run exited non-zero"; exit 1; }
128
+ t "customized statusline preserved (untracked)" "$(grep -cF "$SL_MARKER" .claude/statusline.sh)" "1"
129
+ t "feature keys still absent after repeat upgrades" "$(jq 'has("plans")' .claude/kit.config.json)" "false"
130
+
97
131
  echo ""
98
- [ "$fail" -eq 0 ] && echo "PASS: init.sh --upgrade honors the preserve/exclude contract (#334)" || echo "FAILED"
132
+ [ "$fail" -eq 0 ] && echo "PASS: init.sh --upgrade honors the preserve/exclude contract (#334, #149)" || echo "FAILED"
99
133
  exit "$fail"
package/scripts/init.sh CHANGED
@@ -308,7 +308,9 @@ if [[ $UPGRADE -eq 1 ]]; then
308
308
  [[ -z "$MEMORY" ]] && MEMORY="$(jq -r 'if .memory.enabled then "on" else "off" end' "$UP_CFG")"
309
309
  [[ -z "$SPECKIT" ]] && SPECKIT="$(jq -r 'if (.specKit.enabled // false) then "on" else "off" end' "$UP_CFG")"
310
310
  [[ -z "$LOCAL_LAYER" ]] && LOCAL_LAYER="$(jq -r 'if (.local.enabled // false) then "on" else "off" end' "$UP_CFG")"
311
- [[ -z "$PLANS_FORMAT" ]] && PLANS_FORMAT="$(jq -r '.plans.format // ""' "$UP_CFG")"
311
+ # A config with NO plans key at all deliberately runs without plan files — upgrade must not
312
+ # resurrect the profile default (and with it the plans rule + config block) (#149).
313
+ [[ -z "$PLANS_FORMAT" ]] && PLANS_FORMAT="$(jq -r 'if has("plans") then (.plans.format // "") else "none" end' "$UP_CFG")"
312
314
  [[ "$LANG_PREF" == "English" ]] && LANG_PREF="$(jq -r '.project.language // "English"' "$UP_CFG")"
313
315
  # Skill-name prefix: projects that namespace their kit skills (e.g. "kit-task-close") set
314
316
  # `skillPrefix` so upgrade scaffolds namespaced templates to the matching name instead of
@@ -621,8 +623,16 @@ jq -n \
621
623
  memory:{enabled:$mem,provider:"mempalace",wing:$wing,claudeProjectSlug:$cps}}' \
622
624
  > "$KITCFG.kit-new"
623
625
  if [[ $UPGRADE -eq 1 && -f "$KITCFG" ]]; then
624
- # deep-merge: existing values win (preserve user choices), new keys added, version bumped.
625
- jq -s --arg kitver "$PLUGIN_VERSION" '.[0] * .[1] | .kitVersion = $kitver' "$KITCFG.kit-new" "$KITCFG" \
626
+ # deep-merge: existing values win (preserve user choices), new REQUIRED keys added, version
627
+ # bumped. FEATURE blocks (plans/specKit/prePush/local/memory) are additive only when the
628
+ # project's config ALREADY has them — a missing feature key is a deliberate absence, and an
629
+ # upgrade must never inject profile defaults over it (#149).
630
+ jq -s --arg kitver "$PLUGIN_VERSION" '
631
+ .[1] as $have
632
+ | (.[0] | with_entries(.key as $k | select(
633
+ (["plans","specKit","prePush","local","memory"] | index($k)) == null
634
+ or ($have | has($k))))) as $tmpl
635
+ | $tmpl * $have | .kitVersion = $kitver' "$KITCFG.kit-new" "$KITCFG" \
626
636
  > "$KITCFG.merged" && mv "$KITCFG.merged" "$KITCFG"
627
637
  rm -f "$KITCFG.kit-new"
628
638
  # Existing values win in the merge — but an EXPLICIT --local flag is a user decision now,
@@ -815,9 +825,17 @@ echo " + .claude/settings.local.json${HOOK_NOTE:+ (}${HOOK_NOTE# + }${HOOK_NOTE
815
825
  # Runs on BOTH scaffold and --upgrade so every update re-wires (fixes the class of bug where
816
826
  # /kit-update refreshed files but never re-ran the wiring → statusline/settings drifted). #369
817
827
  if [[ -f "$KIT_ROOT/scripts/kit-wire.sh" ]]; then
828
+ # On --upgrade an EXISTING .claude/statusline.sh follows the same contract as safe_write: the
829
+ # conffiles guard in kit-operate keeps a customized (or untracked) shim; only a shim the kit
830
+ # provably owns intact is refreshed (#149).
831
+ _SHIM="$TARGET/.claude/statusline.sh"
832
+ _shim_before=""; [[ -f "$_SHIM" ]] && _shim_before="$(cat "$_SHIM" 2>/dev/null)"
818
833
  if ( cd "$TARGET" && CLAUDE_PLUGIN_ROOT="$KIT_ROOT" KIT_ASSUME_YES=1 bash "$KIT_ROOT/scripts/kit-wire.sh" >/dev/null 2>&1 ); then
819
834
  echo " + wired: statusline shim + settings.statusLine (kit-wire)"
820
835
  fi
836
+ if [[ $UPGRADE -eq 1 && -n "$_shim_before" && "$_shim_before" == "$(cat "$_SHIM" 2>/dev/null)" ]]; then
837
+ UPGRADE_PRESERVED+=(".claude/statusline.sh")
838
+ fi
821
839
  fi
822
840
 
823
841
  # ---- summary -------------------------------------------------------------
@@ -92,7 +92,10 @@ kit_wire() {
92
92
  _kit_op_say "kit-wire: plugin root = $proot"
93
93
  mkdir -p .claude
94
94
  # 1. statusline shim (tier B — CLI only). kit_op_write_content runs the conffiles machine.
95
- _kit_shim_content | kit_op_write_content "$shim" B wire || return 1
95
+ # rc 10 = kept: a customized/untracked existing shim is PRESERVED (#149) — wiring continues;
96
+ # only a real error aborts. A project that repointed its shim keeps it across updates.
97
+ _kit_shim_content | kit_op_write_content "$shim" B wire
98
+ case $? in 0|10) ;; *) return 1;; esac
96
99
  [ -f "$shim" ] && [ -z "${KIT_DRY_RUN:-}" ] && chmod +x "$shim"
97
100
  # 2. settings statusLine -> shim
98
101
  _kit_wire_settings || true
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # effort-dispatch-test.sh — #151: the `effort)` dispatcher branch in bin/cckit must load the project
4
+ # config BEFORE sourcing/dispatching the effort libs. It shipped without it, so KIT_BASE_BRANCH was
5
+ # unset, `_eff_base` fell back to main, and `cckit effort start` silently created worktrees from
6
+ # origin/main on a non-main-based repo (and the KIT_PROJECTS_V2 board guard never fired via the CLI).
7
+ # Static contract test over bin/cckit: extract the branch block, assert load_kit_config comes first.
8
+ # Run: bash scripts/lib/effort-dispatch-test.sh
9
+ set -u
10
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
11
+ BIN="$ROOT/bin/cckit"
12
+ fail=0
13
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
14
+
15
+ # The effort) branch: from its case label to its terminating `;;` at branch indentation.
16
+ blk="$(awk '/^ effort\)/{f=1} f{print} f && /^ ;;$/{exit}' "$BIN")"
17
+ t "effort) branch found" "$([ -n "$blk" ] && echo yes)" "yes"
18
+
19
+ cfg_ln="$(printf '%s\n' "$blk" | grep -n 'load_kit_config' | head -1 | cut -d: -f1)"
20
+ lib_ln="$(printf '%s\n' "$blk" | grep -n 'source "\$LIB/effort\.sh"' | head -1 | cut -d: -f1)"
21
+ t "effort) loads the project config" "$([ -n "$cfg_ln" ] && echo yes)" "yes"
22
+ t "config load precedes the effort libs" "$([ -n "$cfg_ln" ] && [ -n "$lib_ln" ] && [ "$cfg_ln" -lt "$lib_ln" ] && echo yes)" "yes"
23
+
24
+ [ "$fail" -eq 0 ] && echo "ALL OK"
25
+ exit "$fail"
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # effort-flows-test.sh — #150: the flow vocabulary resolves from the project config, so
4
+ # `cckit effort new --flow X` works out of the box in any configured repo. Resolution order:
5
+ # explicit EFFORT_FLOWS env var (wins) -> effort.flows[] in the project config -> built-in default.
6
+ # Hermetic: throwaway configs pointed at via KIT_CONFIG (no network, no gh).
7
+ # Run: bash scripts/lib/effort-flows-test.sh
8
+ set -u
9
+ ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
10
+ LIB="$ROOT/scripts/lib"
11
+ fail=0
12
+ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
13
+ command -v jq >/dev/null 2>&1 || { echo "effort-flows-test: jq required — skipping"; exit 0; }
14
+
15
+ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
16
+ printf '%s' '{"github":{"repo":"o/r"},"effort":{"flows":["Growth","Checkout","Platform"]}}' > "$tmp/flows.json"
17
+ printf '%s' '{"github":{"repo":"o/r"}}' > "$tmp/noflows.json"
18
+
19
+ # flows_for <cfg> [VAR=val …] — source effort.sh under a given config + env; print resolved EFFORT_FLOWS.
20
+ # KIT_REPO is pre-set so effort.sh's own config bootstrap is skipped — this isolates the #150 resolver.
21
+ flows_for() {
22
+ local cfg="$1"; shift
23
+ env -i PATH="$PATH" HOME="${HOME:-/tmp}" KIT_CONFIG="$cfg" KIT_REPO="o/r" "$@" \
24
+ bash -c "source '$LIB/effort.sh' 2>/dev/null; printf '%s' \"\$EFFORT_FLOWS\""
25
+ }
26
+
27
+ # 1. effort.flows[] in the config replaces the built-in default.
28
+ t "effort.flows[] resolves from the project config" \
29
+ "$(flows_for "$tmp/flows.json")" "Growth Checkout Platform"
30
+ # 2. an explicit EFFORT_FLOWS env var still wins over the config.
31
+ t "EFFORT_FLOWS env var wins over the config" \
32
+ "$(flows_for "$tmp/flows.json" EFFORT_FLOWS="Alpha Beta")" "Alpha Beta"
33
+ # 3. no effort.flows in the config -> the built-in default.
34
+ t "no effort.flows -> built-in default" \
35
+ "$(flows_for "$tmp/noflows.json")" "Core UI API Docs Infra Auth Data Web App"
36
+ # 4. an already-exported KIT_EFFORT_FLOWS (load_kit_config) is honored without re-reading the file.
37
+ t "exported KIT_EFFORT_FLOWS is honored" \
38
+ "$(flows_for "$tmp/noflows.json" KIT_EFFORT_FLOWS="Ops Sales")" "Ops Sales"
39
+
40
+ # 5. the title lint enforces the CONFIGURED vocabulary.
41
+ lint_rc() {
42
+ env -i PATH="$PATH" HOME="${HOME:-/tmp}" KIT_CONFIG="$tmp/flows.json" KIT_REPO="o/r" \
43
+ bash -c "source '$LIB/effort.sh' 2>/dev/null; effort_title_lint \"\$1\" >/dev/null 2>&1" _ "$1"
44
+ }
45
+ lint_rc "[Effort] 9 · [Growth] faster onboarding"; t "lint accepts a config flow" "$?" "0"
46
+ lint_rc "[Effort] 9 · [Core] faster onboarding"; t "lint rejects a flow outside the config vocabulary" "$?" "1"
47
+
48
+ # 6. load_kit_config exports KIT_EFFORT_FLOWS (space-joined) for every downstream consumer.
49
+ t "load_kit_config exports KIT_EFFORT_FLOWS" \
50
+ "$(env -i PATH="$PATH" HOME="${HOME:-/tmp}" KIT_CONFIG="$tmp/flows.json" \
51
+ bash -c "source '$LIB/kit-config.sh'; load_kit_config >/dev/null 2>&1; printf '%s' \"\$KIT_EFFORT_FLOWS\"")" \
52
+ "Growth Checkout Platform"
53
+
54
+ [ "$fail" -eq 0 ] && echo "ALL OK (effort-flows)" || echo "effort-flows: FAILURES"
55
+ exit "$fail"
@@ -25,10 +25,15 @@ case "$1 $2" in
25
25
  "issue edit"|"issue close"|"pr merge") exit 0 ;;
26
26
  "issue view") echo "[Effort] 99 · demo effort" ;; # --json title -q .title
27
27
  "pr create") echo "https://github.com/o/r/pull/7" ;;
28
+ "pr diff") # a merged sub PR's diff (wave-style close, #164): one kit-managed + one app file
29
+ printf 'diff --git a/.claude/skills/demo.md b/.claude/skills/demo.md\n+kit\ndiff --git a/src/app.ts b/src/app.ts\n+app\n' ;;
28
30
  "api "*|"api")
29
31
  case "$*" in
30
32
  *"--method POST"*"/sub_issues"*) exit 0 ;; # link a sub
31
33
  *"/sub_issues"*".[].number"*) printf '101\n102\n' ;; # list subs (for close)
34
+ # wave-style close (#164): per-sub "sub|state|pr|merge-oid|title" rows by parent number
35
+ *closedByPullRequestsReferences*n=77*) printf '301|CLOSED|501|abc1234def|first sub\n302|CLOSED|502|bcd2345eab|second sub\n' ;;
36
+ *closedByPullRequestsReferences*n=78*) printf '201|CLOSED|401|abc1234def|done sub\n202|OPEN|||still open sub\n' ;;
32
37
  *".id"*) echo "55501" ;; # issue db id
33
38
  *) exit 0 ;;
34
39
  esac ;;
@@ -46,11 +51,16 @@ source "$LIB/effort-ops.sh"
46
51
 
47
52
  # ── effort_new ────────────────────────────────────────────────────────────────────────────────
48
53
  : > "$GH_LOG"
49
- parent="$(effort_new "[Core] demo effort" "first sub" "second sub" 2>/dev/null)"
54
+ parent="$(effort_new --flow Core "demo effort" "first sub" "second sub" 2>/dev/null)"
50
55
  t "effort_new returns the parent number" "$parent" "1"
51
56
  t "effort_new creates parent + 2 subs (3 issues)" "$(grep -c 'issue create' "$GH_LOG")" "3"
52
57
  t "effort_new links 2 native sub-issues" "$(grep -c 'method POST .*sub_issues' "$GH_LOG")" "2"
53
58
  tc "$GH_LOG" 'issue create .*--title \[Effort\] · \[Core\] demo effort' "effort_new titles the parent"
59
+ # every kit-defined label is ensured (created idempotently) BEFORE the issue create uses it (#153)
60
+ tc "$GH_LOG" 'label create ctx:' "effort_new ensures the ctx:* label exists"
61
+ tc "$GH_LOG" 'label create kind:task' "effort_new ensures the kind label exists"
62
+ tc "$GH_LOG" 'label create priority:p1' "effort_new ensures the priority label exists"
63
+ tc "$GH_LOG" 'label create flow:core' "effort_new ensures the flow label exists"
54
64
  # a jargon/long name is rejected before any issue is created
55
65
  : > "$GH_LOG"
56
66
  effort_new "refactor the whole scripts/kit wiring layer" >/dev/null 2>&1 && rc=0 || rc=1
@@ -95,18 +105,36 @@ t "effort_close did NOT merge without a trace" "$(grep -c 'pr merge' "$GH_LOG")
95
105
 
96
106
  # ── effort_close #120: happy path — commit present → trace captured → full close ────────────────
97
107
  # A real commit on the effort branch gives snapshot something to trace; close then proceeds through
98
- # capture (pre-squash) → merge → judge/sync → close subs+parent → worktree GC.
108
+ # capture (pre-squash) → merge → judge/sync → close subs+parent → board Done → worktree GC →
109
+ # kit-sync drift check (#148: board Done + drift check moved into the verb from the skill).
99
110
  echo "work" > file.txt
100
- git -c user.email=t@t -c user.name=t add file.txt
111
+ mkdir -p .claude/skills
112
+ echo "kit-managed" > .claude/skills/demo.md # a kit-managed path → the drift check must fire (#148)
113
+ git -c user.email=t@t -c user.name=t add file.txt .claude/skills/demo.md
101
114
  git -c user.email=t@t -c user.name=t commit -q -m "feat: do the thing (#101)"
115
+
116
+ # #148: the VERB sets board Status=Done (guarded). Stub the board helpers + captured ids in-shell —
117
+ # _eo_source_board must see them and skip sourcing the real gh-project.sh.
118
+ BOARD_LOG="$tmp/board.log"; : > "$BOARD_LOG"
119
+ project_find_item_by_issue() { echo "ITEM-$1"; }
120
+ project_set_single_select() { echo "$*" >> "$BOARD_LOG"; }
121
+ export KIT_PROJECTS_V2="true" STATUS_FIELD_ID="SF1" STATUS_OPT_DONE="OPT_DONE"
122
+
102
123
  : > "$GH_LOG"
103
124
  close_out="$(effort_close 99 2>&1)"; rc=$?
125
+ export KIT_PROJECTS_V2="false"
104
126
  cd "$tmp/work" # our cwd (the effort worktree) is GC'd by the close — step to the main checkout
105
127
  t "effort_close succeeds with a trace (rc 0)" "$rc" "0"
106
128
  tc "$GH_LOG" 'pr merge effort/99-demo .*--squash' "effort_close squash-merges the PR"
107
129
  tc "$GH_LOG" 'issue close 101' "effort_close closes sub #101"
108
130
  tc "$GH_LOG" 'issue close 99 ' "effort_close closes the parent"
109
131
  case "$close_out" in *"metrics:"*) echo "ok: capture_effort_metrics composed into close" ;; *) echo "FAIL: no metrics capture in close"; fail=1 ;; esac
132
+ # #148: board Status=Done for the parent + EVERY sub, set by the verb (was skill-only before)
133
+ tc "$BOARD_LOG" 'ITEM-99 SF1 OPT_DONE' "effort_close sets board Done for the parent"
134
+ tc "$BOARD_LOG" 'ITEM-101 SF1 OPT_DONE' "effort_close sets board Done for sub #101"
135
+ tc "$BOARD_LOG" 'ITEM-102 SF1 OPT_DONE' "effort_close sets board Done for sub #102"
136
+ # #148: kit-sync drift check moved into the verb — a kit-managed path in the diff → advisory warning
137
+ case "$close_out" in *"kit-sync"*".claude/skills/demo.md"*) echo "ok: kit-sync drift check warns on kit-managed files" ;; *) echo "FAIL: no kit-sync warning in close output"; fail=1 ;; esac
110
138
  t "effort_close GC removed the effort worktree" \
111
139
  "$(git -C "$tmp/work" worktree list --porcelain | grep -c 'effort+99-demo')" "0"
112
140
  t "effort_close GC deleted the local branch" \
@@ -123,10 +151,40 @@ chmod +x "$stub/khook"
123
151
  start_out="$(effort_start 88 forced 2>/dev/null)"
124
152
  cd "$tmp/work/.claude/worktrees/effort+88-forced"
125
153
  : > "$GH_LOG"
126
- KHOOK_MARKER="$tmp/khook.out" KIT_EFFORT_KNOWLEDGE_HOOK="$stub/khook" KIT_FORCE=1 effort_close 88 >/dev/null 2>&1
154
+ forced_out="$(KHOOK_MARKER="$tmp/khook.out" KIT_EFFORT_KNOWLEDGE_HOOK="$stub/khook" KIT_FORCE=1 effort_close 88 2>&1)"
127
155
  cd "$tmp/work"
128
156
  tc "$GH_LOG" 'pr merge effort/88-forced .*--squash' "KIT_FORCE=1 close merges despite no trace"
129
157
  t "knowledge-ingest hook ran with the effort number" "$(cat "$tmp/khook.out" 2>/dev/null)" "ingested 88"
158
+ # #148: no kit-managed file touched → the drift check stays silent
159
+ case "$forced_out" in *"kit-sync"*) echo "FAIL: kit-sync warning fired with no kit-managed change"; fail=1 ;; *) echo "ok: drift check silent when no kit-managed file changed" ;; esac
160
+
161
+ # ── effort_close #164: WAVE-style close — subs merged as individual task PRs, no effort branch ──
162
+ # Run from the main checkout on a non-effort branch with NO effort/<N>-* branch anywhere: the close
163
+ # must dispatch to the wave path instead of demanding the integration branch.
164
+
165
+ # refuse: a sub still open / lacking a merged PR → list the stragglers, close nothing
166
+ : > "$GH_LOG"
167
+ close_out="$(effort_close 78 2>&1)"; rc=$?
168
+ t "wave close refuses while a sub is open (rc 1)" "$rc" "1"
169
+ case "$close_out" in *"not done"*"#202"*) echo "ok: wave refuse lists the straggler sub" ;; *) echo "FAIL: wave refuse output: $close_out"; fail=1 ;; esac
170
+ t "wave refuse closes nothing" "$(grep -c 'issue close' "$GH_LOG")" "0"
171
+
172
+ # happy: every sub CLOSED with a merged PR → trace from the PR diffs → parent closed, board Done
173
+ # for parent + subs, drift check fires off the union of the merged PR diffs
174
+ : > "$BOARD_LOG"
175
+ export KIT_PROJECTS_V2="true"
176
+ : > "$GH_LOG"
177
+ close_out="$(effort_close 77 2>&1)"; rc=$?
178
+ export KIT_PROJECTS_V2="false"
179
+ t "wave close succeeds when all subs merged (rc 0)" "$rc" "0"
180
+ tc "$GH_LOG" 'pr diff 501' "wave close snapshots the merged sub PR diffs"
181
+ tc "$GH_LOG" 'issue close 77 ' "wave close closes the parent"
182
+ t "wave close closes ONLY the parent (subs already closed)" "$(grep -c 'issue close' "$GH_LOG")" "1"
183
+ t "wave close never squash-merges anything" "$(grep -c 'pr merge' "$GH_LOG")" "0"
184
+ tc "$BOARD_LOG" 'ITEM-77 SF1 OPT_DONE' "wave close sets board Done for the parent"
185
+ tc "$BOARD_LOG" 'ITEM-301 SF1 OPT_DONE' "wave close sets board Done for sub #301"
186
+ tc "$BOARD_LOG" 'ITEM-302 SF1 OPT_DONE' "wave close sets board Done for sub #302"
187
+ case "$close_out" in *"kit-sync"*".claude/skills/demo.md"*) echo "ok: wave drift check reads the merged PR diffs" ;; *) echo "FAIL: no kit-sync warning in wave close output"; fail=1 ;; esac
130
188
 
131
189
  [ "$fail" -eq 0 ] && echo "ALL OK (effort-ops)" || echo "effort-ops: FAILURES"
132
190
  exit "$fail"