@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.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +15 -4
- package/README.md +25 -3
- package/bin/cckit +91 -8
- package/cckit.config.json +1 -1
- package/kit.config.schema.json +43 -2
- package/package.json +1 -1
- package/scripts/autopilot-test.sh +68 -0
- package/scripts/autopilot.sh +16 -10
- package/scripts/check.sh +14 -1
- package/scripts/copilot-loop-test.sh +3 -0
- package/scripts/guard-raw-git-ops-test.sh +73 -0
- package/scripts/init.sh +68 -8
- package/scripts/lib/agent-profile-test.sh +151 -0
- package/scripts/lib/agent-profile.sh +195 -0
- package/scripts/lib/agent-resolve-test.sh +156 -0
- package/scripts/lib/agent-resolve.sh +177 -0
- package/scripts/lib/branch-owner-test.sh +99 -0
- package/scripts/lib/branch-owner.sh +194 -0
- package/scripts/lib/captain-test.sh +86 -0
- package/scripts/lib/captain.sh +142 -7
- package/scripts/lib/contribute-root-test.sh +40 -0
- package/scripts/lib/contribute-root.sh +22 -0
- package/scripts/lib/effort-metrics.sh +14 -1
- package/scripts/lib/effort-ops-test.sh +54 -2
- package/scripts/lib/effort-ops.sh +243 -23
- package/scripts/lib/effort-parity-test.sh +5 -3
- package/scripts/lib/effort-slug.sh +16 -2
- package/scripts/lib/effort.sh +49 -15
- package/scripts/lib/gh-project.sh +14 -0
- package/scripts/lib/gh-rest-test.sh +301 -0
- package/scripts/lib/gh-rest.sh +289 -0
- package/scripts/lib/hook-refresh-test.sh +65 -0
- package/scripts/lib/hook-refresh.sh +62 -0
- package/scripts/lib/kit-config.sh +6 -0
- package/scripts/lib/kit-gc-test.sh +178 -1
- package/scripts/lib/kit-gc.sh +251 -55
- package/scripts/lib/kit-task-ops-test.sh +15 -0
- package/scripts/lib/kit-task-ops.sh +231 -58
- package/scripts/lib/kto-task-close-test.sh +83 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +129 -0
- package/scripts/lib/kto-task-pr-test.sh +59 -0
- package/scripts/lib/orchestration-runtime-test.sh +142 -0
- package/scripts/lib/orchestration-runtime.sh +171 -0
- package/scripts/lib/review-stage-test.sh +241 -0
- package/scripts/lib/review-stage.sh +259 -0
- package/scripts/lib/stage-receipt-test.sh +252 -0
- package/scripts/lib/stage-receipt.sh +442 -0
- package/scripts/lib/test-env-test.sh +25 -0
- package/scripts/lib/test-env.sh +33 -0
- package/scripts/lib/worker-brief-test.sh +120 -0
- package/scripts/lib/worker-brief.sh +185 -0
- package/scripts/lib/worktree-issue.sh +14 -0
- package/scripts/lib/worktree-ports-test.sh +146 -0
- package/scripts/lib/worktree-start.sh +153 -8
- package/scripts/lib/zsh-safety-test.sh +67 -0
- package/scripts/orchestrate.sh +124 -22
- package/scripts/portable-test.sh +22 -1
- package/scripts/review-lint-baseline.txt +28 -0
- package/scripts/review-lint-test.sh +271 -0
- package/scripts/review-lint.sh +259 -0
- package/scripts/review-rules.conf +55 -0
- package/scripts/setup-labels.sh +21 -1
- package/scripts/skill-frontmatter-baseline.txt +24 -0
- package/scripts/skill-frontmatter-lint-test.sh +156 -0
- package/scripts/skill-frontmatter-lint.sh +182 -0
- package/scripts/task-sync.sh +8 -0
- package/scripts/test.sh +10 -1
- package/skills/kit-autopilot/SKILL.md +13 -1
- package/skills/kit-cleanup/SKILL.md +5 -3
- package/skills/kit-contribute/SKILL.md +6 -5
- package/skills/kit-effort-close/SKILL.md +8 -3
- package/skills/kit-effort-pr/SKILL.md +16 -95
- package/skills/kit-gc/SKILL.md +15 -10
- package/skills/kit-security-sweep/SKILL.md +4 -6
- package/skills/kit-ship/SKILL.md +1 -1
- package/skills/kit-task-pr/SKILL.md +2 -0
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +193 -0
- package/templates/rules/branch-naming.md +6 -0
- package/templates/rules/effort-model.md +3 -0
- package/templates/rules/naming-and-ids.md +4 -1
- package/templates/settings/settings.json.tmpl +4 -2
package/skills/kit-gc/SKILL.md
CHANGED
|
@@ -51,7 +51,7 @@ branch's remote** (orphan work is surfaced, never auto-deleted).
|
|
|
51
51
|
# scripts/lib/kit-gc.sh :: kit_gc_analyze (also what `kit gc` + the kit-ui cockpit run)
|
|
52
52
|
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/kit-config.sh" && load_kit_config
|
|
53
53
|
KIT_GC_REPO="$KIT_REPO" source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/kit-gc.sh"
|
|
54
|
-
kit_gc_analyze # worktrees / branches / stashes, each tagged PROTECTED/SAFE/ACTIVE/ORPHAN
|
|
54
|
+
kit_gc_analyze # worktrees / branches / stashes, each tagged PROTECTED/SAFE/ACTIVE/LANDED/ORPHAN
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
Classify every branch/worktree (issue-open protection wins over everything except an explicit force):
|
|
@@ -61,9 +61,10 @@ Classify every branch/worktree (issue-open protection wins over everything excep
|
|
|
61
61
|
| **Protected (open issue)** | `wt_protected_reason` non-empty — associated issue **#N still OPEN** | **keep** — never prune, even with no PR / merged PR |
|
|
62
62
|
| **Safe to delete** | PR `MERGED`, level with its remote (no unpushed commits), **and** issue closed/absent | prune |
|
|
63
63
|
| **Active** | open PR, or the base branch, or a worktree branch with an open PR | keep |
|
|
64
|
-
| **
|
|
64
|
+
| **Landed** | **no PR of its own**, but its work is already on base — either check suffices: (a) *content*: every file it changed since its merge base has the same content on `origin/<base>`; (b) *lineage*: its name (`sub/<N>…`, `effort/<N>…`) or a `[#N]` / `(#N)` in a commit subject names an issue that is **closed with a merged PR** — found in the 200-PR index by head `<kind>/<N>-…`, or, when that PR has scrolled out of the window, through the issue's own `closedByPullRequestsReferences`; a sub-issue with no closing PR (subs close through `effort close`) is resolved once through its **parent**'s closing PR (sub-issues API). One lookup per issue per run, cached | prune, under the same dirty-worktree / unpushed guards as SAFE |
|
|
65
|
+
| **Orphan** | fails both LANDED checks: commits whose content is **not on the base branch's remote** and no merged PR | **surface, never auto-delete** — offer to open a recovery PR |
|
|
65
66
|
|
|
66
|
-
For squash-merged branches, `--is-ancestor`
|
|
67
|
+
For squash-merged branches, `--is-ancestor` and `git cherry` are unreliable (a squash rewrites the patch ids) — trust the **PR state** for a branch with its own PR, and the two LANDED checks for one without: an effort's `sub/<N><letter>` (merged into `effort/<N>`, then squashed), an `effort/<N>` whose remote ref is gone, and a Claude Code Agent-tool isolation worktree (`worktree-agent-<hash>`, which no verb creates). Then verify the branch is level with its remote (`git rev-list --count origin/<b>..<b>` = 0) before deleting. The LANDED row carries its reason (`content on origin/develop`, `issue #50 closed, its PR merged`; agent worktrees are named as such).
|
|
67
68
|
|
|
68
69
|
### 2. Present the plan
|
|
69
70
|
|
|
@@ -71,18 +72,21 @@ Print a table: worktrees to remove, branches to delete (local + remote), orphans
|
|
|
71
72
|
|
|
72
73
|
### 3. Execute (after confirmation)
|
|
73
74
|
|
|
75
|
+
Every deletion goes through the verb — the raw `git worktree remove` / `git branch -D` loop this
|
|
76
|
+
section used to document is what the base-branch guard exists to prevent, and it skipped the
|
|
77
|
+
recover-before-prune checks. `/kit-cleanup` prints the same plan, then acts on it:
|
|
78
|
+
|
|
74
79
|
```bash
|
|
75
|
-
#
|
|
76
|
-
git worktree remove <path> --force && git worktree prune
|
|
77
|
-
# Merged branches — local then remote
|
|
78
|
-
git branch -D <branch>
|
|
79
|
-
git push origin --delete <branch>
|
|
80
|
+
cckit cleanup --yes # deletes the SAFE + LANDED rows (worktree, local branch, level remote ref), prunes listed ZOMBIE metadata
|
|
80
81
|
# Stale-open issues (PR already merged)
|
|
81
|
-
|
|
82
|
-
# Stashes — only after showing each diff and getting an explicit OK
|
|
82
|
+
cckit close <n> "Delivered via PR #<pr>." # board Done + close; raw gh issue close is blocked (#364)
|
|
83
|
+
# Stashes — the one step that stays by hand, only after showing each diff and getting an explicit OK
|
|
83
84
|
git stash drop 'stash@{n}' # or: git stash clear
|
|
84
85
|
```
|
|
85
86
|
|
|
87
|
+
A branch that `cleanup` leaves as ORPHAN is one whose work is **not** on base by either check: do not
|
|
88
|
+
reach for `git branch -D` — step 4.
|
|
89
|
+
|
|
86
90
|
### 4. Orphan handling
|
|
87
91
|
|
|
88
92
|
For each orphan branch with unique unpushed work: **do not delete**. Recover it
|
|
@@ -95,5 +99,6 @@ into a clean PR off the base branch (branch from `$BASE`, `git checkout <orphan>
|
|
|
95
99
|
- **Never** delete the base branch (`main`/`develop`) or an open-PR branch/worktree.
|
|
96
100
|
- **Never** remove a worktree/branch whose **associated issue is still open** (`wt_protected_reason` non-empty) — close the issue first, or pass an explicit per-item override.
|
|
97
101
|
- **Never** drop a stash or delete an orphan branch without explicit per-item consent (stashes and unpushed commits are irreversible).
|
|
102
|
+
- **Delete through `cckit cleanup --yes`**, never a raw `git worktree remove` / `git branch -D` — the verb is the only path that applies the recover-before-prune guards to every row it touches.
|
|
98
103
|
- Verify a branch is **level with its remote** before deleting — an "ahead" branch may hold orphan work.
|
|
99
104
|
- Prefer enabling GitHub **"Automatically delete head branches"** so remote pruning stops being a manual step.
|
|
@@ -31,12 +31,10 @@ Ask it to output findings grouped by severity + a flat "Issues to file" list at
|
|
|
31
31
|
For each finding, create a GitHub issue on the project repo (`KIT_REPO` from kit.config):
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
--body "<risk / evidence / fix>"
|
|
39
|
-
# add --milestone "<Security milestone>" when the project has one
|
|
34
|
+
cckit new --role security --kind security --priority <critical|p1|p2|p3> \
|
|
35
|
+
--body-file <finding.md> "<finding title>"
|
|
36
|
+
# add --milestone "<Security milestone>" when the project has one. The verb adds the issue to the
|
|
37
|
+
# board; raw gh issue create is blocked by the guard hook (#364).
|
|
40
38
|
```
|
|
41
39
|
|
|
42
40
|
### Phase 3 — Roadmap (Tech Lead)
|
package/skills/kit-ship/SKILL.md
CHANGED
|
@@ -29,7 +29,7 @@ resolve from `${CLAUDE_PLUGIN_ROOT}`.
|
|
|
29
29
|
| 5 | **PR** | `/kit-task-pr <N>` — commit, push, open PR to the base branch, mirror labels/milestone, add to board, move issue **In Review**. |
|
|
30
30
|
| 6 | **Wait for CI** | If the project has a required check, poll until it's not pending (background `until` loop). **Pending ≠ failing — wait; never force-merge.** |
|
|
31
31
|
| 7 | **Merge** | `/kit-task-pr-merge` once green — squash to the base, switch to base, pull, delete local+remote branch + worktree. |
|
|
32
|
-
| 8 | **Close** | `
|
|
32
|
+
| 8 | **Close** | `cckit close <N> "<summary>"` — closes the issue and sets board **Done**. **Required** when `Closes #N` does NOT auto-fire (PRs that merge to a non-default branch don't trigger GitHub auto-close). |
|
|
33
33
|
| 9 | **Update kit (only if the change touched the plugin source)** | bump version (`/kit-dev ship`) + `/plugin update`. |
|
|
34
34
|
|
|
35
35
|
Report at the end: issue state, PR number + merged status, branch cleaned, board reflects Done.
|
|
@@ -40,4 +40,6 @@ The function prints `✓ <PR-URL>`.
|
|
|
40
40
|
- Never open a PR for a branch off the `<kind>/<N>-<slug>` convention — the op aborts with instructions
|
|
41
41
|
- Never invent a Summary — ask if missing (the op refuses an empty Summary) · never push to the base branch directly
|
|
42
42
|
- PR mirrors issue labels · if no milestone, the op omits it (no block)
|
|
43
|
+
- Commits **tracked** changes only; untracked files are listed and left alone (`git add` them first if they belong), so a copied `.env.local` never reaches a PR
|
|
44
|
+
- Title and body follow `pr.titleStyle` and `pr.orchestratorSection` in the config (`config-and-permissions` docs)
|
|
43
45
|
- If `gh pr create` fails because the branch hasn't diverged, the op surfaces the error verbatim (likely forgot to commit)
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# guard-raw-git-ops.sh — PreToolUse(Bash) hook. Scaffolded by cckit (#364).
|
|
3
|
+
#
|
|
4
|
+
# In a repo with a cckit config, the verbs own the side effects of the GitHub lifecycle: board add,
|
|
5
|
+
# Role/Status fields, labels, milestone, the worktree claim, the trace. A raw `gh issue create`
|
|
6
|
+
# skips every one of them, silently. This hook blocks the raw form and prints the verb to run:
|
|
7
|
+
#
|
|
8
|
+
# gh issue create -> cckit new --role <role> "<title>" (multi-part: cckit effort new)
|
|
9
|
+
# gh pr create -> cckit pr <issue> "<summary>" (effort: cckit effort pr <N>)
|
|
10
|
+
# gh pr merge -> cckit merge [<pr>] (effort: cckit effort close <N>)
|
|
11
|
+
# gh issue close -> cckit close <issue> "<summary>"
|
|
12
|
+
# git checkout -b / switch -c / worktree add, on the base branch
|
|
13
|
+
# -> cckit start <issue> (effort: cckit effort start <N>)
|
|
14
|
+
#
|
|
15
|
+
# Only the agent's OWN command is inspected. The gh/git calls the verbs make internally run in a
|
|
16
|
+
# child process, which this hook never sees, so the verbs cannot trip it.
|
|
17
|
+
#
|
|
18
|
+
# Escape hatch, recorded: prefix the command with KIT_ALLOW_RAW=1 (or export it). Each bypass is
|
|
19
|
+
# appended to <git-common-dir>/cckit/raw-bypass.log, so the trail survives worktree removal.
|
|
20
|
+
#
|
|
21
|
+
# Exit 2 blocks (the agent sees stderr). Fails OPEN on anything ambiguous: no jq, no command, no
|
|
22
|
+
# git repo, no cckit config. A guard must never block work it cannot read.
|
|
23
|
+
# Self-test: bash <this file> --selftest
|
|
24
|
+
|
|
25
|
+
set -uo pipefail
|
|
26
|
+
|
|
27
|
+
# _grg_strip <cmd> — drop the text that is never executed: single-quoted strings and heredoc
|
|
28
|
+
# bodies. A commit message or a doc snippet that MENTIONS `gh pr create` is not a call to it.
|
|
29
|
+
_grg_strip() {
|
|
30
|
+
printf '%s\n' "$1" | awk '
|
|
31
|
+
term != "" { t=$0; sub(/^[ \t]+/, "", t); if (t == term) term=""; next }
|
|
32
|
+
{
|
|
33
|
+
line=$0
|
|
34
|
+
if (match(line, /<<-?[ \t]*["\x27]?[A-Za-z_][A-Za-z0-9_]*/)) {
|
|
35
|
+
h=substr(line, RSTART, RLENGTH); gsub(/^<<-?[ \t]*["\x27]?/, "", h); term=h
|
|
36
|
+
}
|
|
37
|
+
gsub(/\x27[^\x27]*\x27/, "\x27\x27", line)
|
|
38
|
+
print line
|
|
39
|
+
}'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# _grg_segments <cmd> — one simple command per line: split on ; & | ( ) { } ` and newlines, trim,
|
|
43
|
+
# then drop leading VAR=value assignments and wrapper words (command exec env time nohup sudo).
|
|
44
|
+
_grg_segments() {
|
|
45
|
+
_grg_strip "$1" | tr ';&|(){}`' '\n\n\n\n\n\n\n\n' | sed -E \
|
|
46
|
+
-e 's/^[[:space:]]+//' \
|
|
47
|
+
-e ':a' -e 's/^[A-Za-z_][A-Za-z0-9_]*=[^[:space:]]*[[:space:]]+//' -e 'ta' \
|
|
48
|
+
-e ':b' -e 's/^(command|exec|env|time|nohup|sudo)[[:space:]]+//' -e 'tb' \
|
|
49
|
+
-e 's/^\$//' -e 's/^[[:space:]]+//'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# _grg_classify <segment> — print the raw-op key for one simple command, or nothing.
|
|
53
|
+
_grg_classify() {
|
|
54
|
+
local s="$1"
|
|
55
|
+
# `--help` / `-h` only prints usage: read-only, never a bypass.
|
|
56
|
+
printf '%s' "$s" | grep -qE '[[:space:]](--help|-h)([[:space:]]|$)' && return 0
|
|
57
|
+
if printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+issue[[:space:]]+create([[:space:]]|$)'; then echo issue-create
|
|
58
|
+
elif printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+issue[[:space:]]+close([[:space:]]|$)'; then echo issue-close
|
|
59
|
+
elif printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+pr[[:space:]]+create([[:space:]]|$)'; then echo pr-create
|
|
60
|
+
elif printf '%s' "$s" | grep -qE '^gh([[:space:]]+(-R|--repo)[[:space:]]+[^[:space:]]+|[[:space:]]+--repo=[^[:space:]]+)*[[:space:]]+pr[[:space:]]+merge([[:space:]]|$)'; then echo pr-merge
|
|
61
|
+
elif printf '%s' "$s" | grep -qE '^git([[:space:]]+-C[[:space:]]+[^[:space:]]+)*[[:space:]]+(checkout[[:space:]]+(.*[[:space:]])?-[bB]|switch[[:space:]]+(.*[[:space:]])?(-c|-C|--create)|worktree[[:space:]]+add)([[:space:]]|$)'; then echo branch
|
|
62
|
+
fi
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# _grg_hint <key> — the verb to run instead.
|
|
66
|
+
_grg_hint() { # <key> [segment] — the segment's flags pick the matching verb flag (#376/#377)
|
|
67
|
+
local seg="${2:-}" n
|
|
68
|
+
case "$1" in
|
|
69
|
+
issue-create) echo 'cckit new --role <role> [--kind K --priority P --body-file F] "<title>" (multi-part work: cckit effort new)' ;;
|
|
70
|
+
issue-close)
|
|
71
|
+
n="$(printf '%s' "$seg" | sed -nE 's/.*--duplicate-of[= ]+#?([0-9]+).*/\1/p')"
|
|
72
|
+
if [ -n "$n" ]; then echo "cckit close <issue> --duplicate-of $n (state_reason duplicate, board Done)"
|
|
73
|
+
elif printf '%s' "$seg" | grep -qiE -- '(--reason|-r)[= ]+.?not[ _-]?planned'; then
|
|
74
|
+
echo 'cckit close <issue> "<why>" --reason not-planned (superseded: --superseded-by <N>)'
|
|
75
|
+
else echo 'cckit close <issue> "<summary>" [--reason completed|not-planned|duplicate] (an effort: cckit effort close <N>)'; fi ;;
|
|
76
|
+
pr-create) echo 'cckit pr <issue> "<summary>" (an effort: cckit effort pr <N> --summary-file F --for-agents-file F)' ;;
|
|
77
|
+
pr-merge)
|
|
78
|
+
if printf '%s' "$seg" | grep -qE -- '(--merge|-m)([[:space:]]|$)'; then echo 'cckit merge [<pr>] --merge (a merge commit; also into an effort/<N> base)'
|
|
79
|
+
elif printf '%s' "$seg" | grep -qE -- '(--rebase|-r)([[:space:]]|$)'; then echo 'cckit merge [<pr>] --rebase'
|
|
80
|
+
else echo 'cckit merge [<pr>] [--merge|--rebase] (an effort: cckit effort close <N>)'; fi ;;
|
|
81
|
+
branch) echo 'cckit start <issue> (an effort: cckit effort start <N>)' ;;
|
|
82
|
+
esac
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# _grg_config <dir> — the cckit config governing <dir>, or rc 1 (same walk as config-path.sh).
|
|
86
|
+
_grg_config() {
|
|
87
|
+
local d; d="$(cd "${1:-.}" 2>/dev/null && pwd)" || return 1
|
|
88
|
+
while [ -n "$d" ]; do
|
|
89
|
+
[ -f "$d/cckit.config.json" ] && { printf '%s\n' "$d/cckit.config.json"; return 0; }
|
|
90
|
+
[ -f "$d/.claude/kit.config.json" ] && { printf '%s\n' "$d/.claude/kit.config.json"; return 0; }
|
|
91
|
+
[ "$d" = "/" ] && break
|
|
92
|
+
d="$(dirname "$d")"
|
|
93
|
+
done
|
|
94
|
+
return 1
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_grg_selftest() {
|
|
98
|
+
local fail=0 c want got
|
|
99
|
+
while IFS='|' read -r want c; do
|
|
100
|
+
[ -z "$c" ] && continue
|
|
101
|
+
got=""
|
|
102
|
+
while IFS= read -r seg; do
|
|
103
|
+
[ -z "$seg" ] && continue
|
|
104
|
+
k="$(_grg_classify "$seg")"; [ -n "$k" ] && { got="$k"; break; }
|
|
105
|
+
done <<< "$(_grg_segments "$c")"
|
|
106
|
+
if [ "$got" = "$want" ]; then echo "ok: [$want] $c"; else echo "FAIL: '$c' -> got '$got' want '$want'"; fail=1; fi
|
|
107
|
+
done <<'CASES'
|
|
108
|
+
issue-create|gh issue create --title x --body y
|
|
109
|
+
issue-create|gh -R o/r issue create -t x
|
|
110
|
+
issue-create|cd /tmp && gh issue create -t x
|
|
111
|
+
issue-create|url=$(gh issue create -t x)
|
|
112
|
+
issue-create|FOO=1 gh issue create -t x
|
|
113
|
+
pr-create|gh pr create --base develop
|
|
114
|
+
pr-create|git push -u origin HEAD; gh pr create --fill
|
|
115
|
+
pr-merge|gh pr merge 12 --squash
|
|
116
|
+
pr-merge|gh --repo o/r pr merge 12
|
|
117
|
+
issue-close|gh issue close 5 --comment done
|
|
118
|
+
branch|git checkout -b feat/1-x
|
|
119
|
+
branch|git -C /tmp/r switch -c feat/1-x
|
|
120
|
+
branch|git worktree add ../wt -b feat/1-x
|
|
121
|
+
branch|git checkout -q -b feat/1-x origin/develop
|
|
122
|
+
|gh issue view 5
|
|
123
|
+
|gh issue close --help
|
|
124
|
+
|gh pr merge -h
|
|
125
|
+
|gh pr list --state open
|
|
126
|
+
|gh pr view 7 --json body
|
|
127
|
+
|git checkout develop
|
|
128
|
+
|git switch feat/1-x
|
|
129
|
+
|git commit -m 'never run gh pr create by hand'
|
|
130
|
+
|rg -n 'gh issue create' .claude
|
|
131
|
+
|cckit pr 12 "summary"
|
|
132
|
+
|cckit new --role tech-lead "title"
|
|
133
|
+
|echo 'gh pr merge 1'
|
|
134
|
+
CASES
|
|
135
|
+
# heredoc bodies are data, not commands
|
|
136
|
+
got=""; while IFS= read -r seg; do k="$(_grg_classify "$seg")"; [ -n "$k" ] && got="$k"; done \
|
|
137
|
+
<<< "$(_grg_segments "$(printf 'cat > f.md <<EOF\ngh pr create --fill\nEOF\necho done')")"
|
|
138
|
+
if [ -z "$got" ]; then echo "ok: heredoc body ignored"; else echo "FAIL: heredoc body classified as $got"; fail=1; fi
|
|
139
|
+
return "$fail"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
[ "${1:-}" = "--selftest" ] && { _grg_selftest; exit $?; }
|
|
143
|
+
|
|
144
|
+
command -v jq >/dev/null 2>&1 || exit 0
|
|
145
|
+
input="$(cat 2>/dev/null)"
|
|
146
|
+
cmd="$(printf '%s' "$input" | jq -r '.tool_input.command // empty' 2>/dev/null)"
|
|
147
|
+
[ -z "$cmd" ] && exit 0
|
|
148
|
+
# Cheap prefilter: nothing to inspect unless gh or git appears at all.
|
|
149
|
+
printf '%s' "$cmd" | grep -qE '(^|[^A-Za-z0-9_-])(gh|git)[[:space:]]' || exit 0
|
|
150
|
+
|
|
151
|
+
key=""; hit=""
|
|
152
|
+
while IFS= read -r seg; do
|
|
153
|
+
[ -z "$seg" ] && continue
|
|
154
|
+
key="$(_grg_classify "$seg")"; [ -n "$key" ] && { hit="$seg"; break; }
|
|
155
|
+
done <<< "$(_grg_segments "$cmd")"
|
|
156
|
+
[ -z "$key" ] && exit 0
|
|
157
|
+
|
|
158
|
+
# Resolve the directory the command runs in (as guard-base-branch-commit does): `git -C <dir>`, a
|
|
159
|
+
# leading `cd <dir>`, else the tool's cwd.
|
|
160
|
+
cwd="$(printf '%s' "$input" | jq -r '.cwd // empty' 2>/dev/null)"
|
|
161
|
+
dir=""
|
|
162
|
+
if [[ "$cmd" =~ git[[:space:]]+-C[[:space:]]+([^[:space:]]+) ]]; then dir="${BASH_REMATCH[1]}"
|
|
163
|
+
elif [[ "$cmd" =~ (^|[\&\;\|])[[:space:]]*cd[[:space:]]+([^[:space:]\&\;\|]+) ]]; then dir="${BASH_REMATCH[2]}"; fi
|
|
164
|
+
dir="${dir%\"}"; dir="${dir#\"}"; dir="${dir%\'}"; dir="${dir#\'}"
|
|
165
|
+
case "$dir" in ""|*'$'*) dir="${cwd:-${CLAUDE_PROJECT_DIR:-$PWD}}" ;; esac
|
|
166
|
+
|
|
167
|
+
cfg="$(_grg_config "$dir")" || exit 0 # not a cckit repo: not our business
|
|
168
|
+
|
|
169
|
+
# A branch op is only a bypass when it cuts work from the base branch (cckit start's job).
|
|
170
|
+
# Branching inside an issue or effort worktree (a sub branch, a scratch branch) is fine.
|
|
171
|
+
if [ "$key" = branch ]; then
|
|
172
|
+
base="$(jq -r '.github.baseBranch // .git.baseBranch // empty' "$cfg" 2>/dev/null)"
|
|
173
|
+
cur="$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null)" || exit 0
|
|
174
|
+
case "$cur" in "${base:-develop}"|main|master|develop) : ;; *) exit 0 ;; esac
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
if [ "${KIT_ALLOW_RAW:-}" = 1 ] || printf '%s' "$cmd" | grep -qE '(^|[^A-Za-z0-9_])KIT_ALLOW_RAW=1([[:space:]]|$)'; then
|
|
178
|
+
common="$(git -C "$dir" rev-parse --path-format=absolute --git-common-dir 2>/dev/null)"
|
|
179
|
+
if [ -n "$common" ]; then
|
|
180
|
+
mkdir -p "$common/cckit" 2>/dev/null
|
|
181
|
+
printf '%s\t%s\t%s\t%s\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$key" "$dir" \
|
|
182
|
+
"$(printf '%s' "$cmd" | tr '\n\t' ' ' | cut -c1-300)" >> "$common/cckit/raw-bypass.log" 2>/dev/null
|
|
183
|
+
fi
|
|
184
|
+
echo "cckit: raw $key allowed by KIT_ALLOW_RAW=1 — recorded in ${common:-<no git dir>}/cckit/raw-bypass.log" >&2
|
|
185
|
+
exit 0
|
|
186
|
+
fi
|
|
187
|
+
|
|
188
|
+
{
|
|
189
|
+
echo "BLOCKED: raw '$key' in a cckit repo. The verb owns the side effects (board, labels, worktree); the raw command skips them silently."
|
|
190
|
+
echo "Run instead: $(_grg_hint "$key" "${hit:-}")"
|
|
191
|
+
echo "If the verb is broken, fix the verb. Deliberate one-off: prefix KIT_ALLOW_RAW=1 (recorded in <git-common-dir>/cckit/raw-bypass.log)."
|
|
192
|
+
} >&2
|
|
193
|
+
exit 2
|
|
@@ -81,6 +81,12 @@ Lockfiles (`pnpm-lock.yaml`, `package-lock.json`, …) and manifest config confl
|
|
|
81
81
|
**Two agents in the same git checkout corrupt each other.** The working tree, index, and `HEAD` are a single unguarded shared resource: one agent's `mv`/`add`/`stage` is silently clobbered by another's `reset`/`checkout`/`stash`/`rebase`. Git has no locking for this.
|
|
82
82
|
|
|
83
83
|
- **One agent = one git worktree** (or a separate clone). Never two agents in the same directory.
|
|
84
|
+
- **`orchestrate` enforces this with a lease, not just prose.** Git refuses one branch in two
|
|
85
|
+
worktrees; it does not stop two agent processes from driving the branch cckit handed them. Every
|
|
86
|
+
branch in a wave is claimed before any pane starts (`scripts/lib/branch-owner.sh`), a branch a
|
|
87
|
+
live writer already owns refuses the launch, and the wave's other claims are released. A lease is
|
|
88
|
+
reclaimed only on positive evidence — its worktree is gone, or its process died on the host that
|
|
89
|
+
recorded it — never on a process check against another host.
|
|
84
90
|
- Prefer giving local sub-agents their own worktree.
|
|
85
91
|
- Remote CI agents (Auto-Dev) are isolated per runner — favor them for parallel fixes.
|
|
86
92
|
- Before editing shared files, check whether another agent is active.
|
|
@@ -197,6 +197,9 @@ The parent issue **is** the plan. Strategy / roadmap narrative lives in your kno
|
|
|
197
197
|
|
|
198
198
|
- Snapshot each sub-branch diff **before squash** (squash destroys per-sub-issue pairs) — `effort-close`
|
|
199
199
|
step (a) does this automatically, to a durable dir under the shared git-common-dir.
|
|
200
|
+
- `index.jsonl` is the completeness marker, not the presence of a `.diff`. The snapshot moves it
|
|
201
|
+
into place only once every record is written, and `effort-close` step (a2) refuses the squash
|
|
202
|
+
unless it is non-empty. A `.diff` on disk proves a file was created, not that the trace is whole.
|
|
200
203
|
- Scrub secrets from diffs/bodies before they enter an issue or any exported record.
|
|
201
204
|
- Keep client/tenant data out of the dev-workflow record (it is not your development history).
|
|
202
205
|
- Outcome labels: merged-clean = positive · abandoned/reverted = negative · a manual flag for exemplars.
|
|
@@ -165,6 +165,7 @@ nobody consumes.
|
|
|
165
165
|
| `flow:` | `core` `docs` … | effort dispatch | which flow owns it |
|
|
166
166
|
| `role:` | `tech-lead` `docs` … | delegation brief | who it is written for |
|
|
167
167
|
| `kind:` | must discriminate | board grouping | what sort of work it is |
|
|
168
|
+
| `agent:` | one per declared profile | `ap_profile_from_labels` | which agent profile runs the work |
|
|
168
169
|
| `slug:` | one per effort | `effort_slug_resolve` | resolve a name to an effort |
|
|
169
170
|
|
|
170
171
|
### Rules
|
|
@@ -177,7 +178,9 @@ nobody consumes.
|
|
|
177
178
|
anything unknown, so an `XL` effort with no `ctx:XL` label silently weighs the same as an `M`.
|
|
178
179
|
A scale the code knows but the board cannot express is a scale that quietly misreports.
|
|
179
180
|
- **Do not create per-item labels beyond `slug:`.** They grow without bound and match one issue
|
|
180
|
-
each, which makes them useless as a board axis.
|
|
181
|
+
each, which makes them useless as a board axis. `agent:<profile>` is not one of these: it is
|
|
182
|
+
bounded by the profiles the config declares, and `scripts/setup-labels.sh` provisions exactly
|
|
183
|
+
those, so the family stays a board axis rather than a per-issue tag.
|
|
181
184
|
- **Leave `autorelease:*` alone** — release-please owns those.
|
|
182
185
|
|
|
183
186
|
### Priority means urgency, not membership
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"permissions": {
|
|
3
|
-
"comment": "Versioned (checked-in) permissions so they travel to every worktree and scaffolded project. Captain default: merging each green wave PR under an APPROVED plan is pre-authorized execution (kit-autopilot, established-plan autonomy) — the explicit merge
|
|
3
|
+
"comment": "Versioned (checked-in) permissions so they travel to every worktree and scaffolded project. Captain default: merging each green wave PR under an APPROVED plan is pre-authorized execution (kit-autopilot, established-plan autonomy) — the explicit merge rules keep auto-mode from prompting on a planned merge. Merges go through the verbs: raw gh pr merge is blocked by guard-raw-git-ops.sh.",
|
|
4
4
|
"allow": [
|
|
5
|
-
"Bash(
|
|
5
|
+
"Bash(cckit merge:*)",
|
|
6
|
+
"Bash(cckit watch:*)",
|
|
7
|
+
"Bash(cckit effort close:*)",
|
|
6
8
|
"Bash(cckit orchestrate:*)"
|
|
7
9
|
]
|
|
8
10
|
}
|