@jeiemgi/cckit 0.11.0 → 0.12.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 (121) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/AGENTS.md +45 -41
  3. package/README.md +39 -29
  4. package/bin/cckit +111 -70
  5. package/cckit.config.json +1 -1
  6. package/package.json +1 -1
  7. package/scripts/advisor-test.sh +55 -0
  8. package/scripts/autopilot.sh +4 -4
  9. package/scripts/capture-project-ids.sh +16 -0
  10. package/scripts/check.sh +6 -0
  11. package/scripts/content-skills-test.sh +1 -1
  12. package/scripts/copilot-loop-test.sh +8 -8
  13. package/scripts/force-push-fence-test.sh +44 -0
  14. package/scripts/force-push-fence.baseline +1 -0
  15. package/scripts/force-push-fence.sh +51 -0
  16. package/scripts/init.sh +2 -2
  17. package/scripts/instruction-budget-baseline.txt +1 -1
  18. package/scripts/kit-doctor-test.sh +5 -0
  19. package/scripts/kit-doctor.sh +96 -2
  20. package/scripts/lib/agent-resolve-test.sh +2 -0
  21. package/scripts/lib/agent-resolve.sh +3 -2
  22. package/scripts/lib/board-view.sh +3 -3
  23. package/scripts/lib/captain.sh +1 -1
  24. package/scripts/lib/copilot-test.sh +4 -4
  25. package/scripts/lib/copilot.sh +13 -13
  26. package/scripts/lib/effort-close-subs-test.sh +96 -0
  27. package/scripts/lib/effort-dispatch-test.sh +2 -2
  28. package/scripts/lib/effort-ops-test.sh +98 -9
  29. package/scripts/lib/effort-ops.sh +390 -63
  30. package/scripts/lib/effort-parity-test.sh +37 -31
  31. package/scripts/lib/effort-plan.sh +3 -3
  32. package/scripts/lib/effort-review-test.sh +107 -0
  33. package/scripts/lib/effort-review.sh +93 -0
  34. package/scripts/lib/effort-slug-test.sh +4 -0
  35. package/scripts/lib/effort-slug.sh +5 -4
  36. package/scripts/lib/effort.sh +47 -74
  37. package/scripts/lib/forge-github.sh +18 -7
  38. package/scripts/lib/gh-board-add-test.sh +118 -0
  39. package/scripts/lib/gh-project-test.sh +115 -0
  40. package/scripts/lib/gh-project.sh +128 -6
  41. package/scripts/lib/gh-rest-test.sh +12 -8
  42. package/scripts/lib/gh-rest.sh +189 -15
  43. package/scripts/lib/git-core-test.sh +2 -2
  44. package/scripts/lib/grill-record-test.sh +49 -0
  45. package/scripts/lib/grill-record.sh +88 -0
  46. package/scripts/lib/handoff.sh +1 -1
  47. package/scripts/lib/kit-brief-test.sh +29 -0
  48. package/scripts/lib/kit-brief.sh +91 -6
  49. package/scripts/lib/kit-lib-test.sh +1 -1
  50. package/scripts/lib/kit-lib.sh +7 -7
  51. package/scripts/lib/kit-msg.sh +3 -3
  52. package/scripts/lib/kit-status.sh +1 -1
  53. package/scripts/lib/kit-task-ops-test.sh +17 -0
  54. package/scripts/lib/kit-task-ops.sh +73 -22
  55. package/scripts/lib/kto-task-new-test.sh +18 -0
  56. package/scripts/lib/kto-task-pr-merge-test.sh +44 -0
  57. package/scripts/lib/kto-task-pr-test.sh +3 -3
  58. package/scripts/lib/light-task.sh +16 -1
  59. package/scripts/lib/loose-issues.sh +65 -0
  60. package/scripts/lib/naming-test.sh +112 -0
  61. package/scripts/lib/naming-verbs-test.sh +126 -0
  62. package/scripts/lib/naming.sh +172 -0
  63. package/scripts/lib/next-test.sh +1 -1
  64. package/scripts/lib/next.sh +6 -6
  65. package/scripts/lib/plan-machine.sh +9 -9
  66. package/scripts/lib/plan-next.sh +4 -4
  67. package/scripts/lib/qa-lane.sh +1 -1
  68. package/scripts/lib/spec-lint-test.sh +63 -0
  69. package/scripts/lib/spec-lint.sh +95 -0
  70. package/scripts/lib/sprint-test.sh +96 -0
  71. package/scripts/lib/sprint.sh +216 -0
  72. package/scripts/lib/stage-receipt-test.sh +132 -0
  73. package/scripts/lib/stage-receipt.sh +184 -5
  74. package/scripts/lib/test-forge-shim.sh +2 -1
  75. package/scripts/lib/verbs.sh +1 -1
  76. package/scripts/lib/verbs.tsv +17 -15
  77. package/scripts/lib/worker-brief-test.sh +1 -1
  78. package/scripts/lib/worker-brief.sh +1 -1
  79. package/scripts/lib/worktree-start.sh +42 -1
  80. package/scripts/loose-issues-test.sh +102 -0
  81. package/scripts/loose-issues.baseline +5 -0
  82. package/scripts/night-grant.sh +1 -1
  83. package/scripts/portable-test.sh +1 -1
  84. package/scripts/status-test.sh +1 -1
  85. package/scripts/status.sh +4 -4
  86. package/scripts/task-sync-test.sh +34 -0
  87. package/scripts/task-sync.sh +81 -1
  88. package/scripts/terms-check.sh +1 -1
  89. package/scripts/verbs-ratchet-test.sh +6 -1
  90. package/scripts/verbs-test.sh +4 -4
  91. package/scripts/verbs.baseline +1 -1
  92. package/skills/kit-add/SKILL.md +1 -1
  93. package/skills/kit-advisor/SKILL.md +75 -0
  94. package/skills/kit-advisor/references/close.md +53 -0
  95. package/skills/kit-advisor/references/grill.md +69 -0
  96. package/skills/kit-advisor/references/orchestrate.md +56 -0
  97. package/skills/kit-advisor/references/plan.md +64 -0
  98. package/skills/kit-advisor/references/review.md +47 -0
  99. package/skills/kit-advisor/references/step-report.md +61 -0
  100. package/skills/kit-autopilot/SKILL.md +1 -1
  101. package/skills/kit-cleanup/SKILL.md +2 -2
  102. package/skills/kit-effort-close/SKILL.md +16 -8
  103. package/skills/kit-effort-new/SKILL.md +11 -8
  104. package/skills/kit-effort-pr/SKILL.md +7 -7
  105. package/skills/kit-next/SKILL.md +7 -7
  106. package/skills/kit-plan-next/SKILL.md +10 -11
  107. package/skills/kit-status/SKILL.md +5 -5
  108. package/skills/kit-task-pr-auto/SKILL.md +1 -1
  109. package/skills/kit-task-pr-merge/SKILL.md +3 -3
  110. package/skills/kit-task-sync/SKILL.md +2 -0
  111. package/skills/routing.yaml +5 -0
  112. package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
  113. package/templates/instructions.md.tmpl +3 -3
  114. package/templates/rules/authoring.md +7 -3
  115. package/templates/rules/delegation-brief.md +4 -0
  116. package/templates/rules/effort-model.md +34 -31
  117. package/templates/rules/gate-and-review.md +1 -1
  118. package/templates/rules/merge-safety.md +9 -7
  119. package/templates/rules/naming-and-ids.md +20 -24
  120. package/templates/rules/plan-next.md +5 -5
  121. package/templates/skills/campaign/SKILL.md +2 -2
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # grill-record.sh — the `## Grilling` record on an effort body (the advisor's grill stage, E547.2).
4
+ # The grill stage runs one interview, plays the understanding back, and the owner confirms it. What
5
+ # lands in the effort body is the confirmed record, never the raw interview. `cckit effort new
6
+ # --grilling T | --grilling-file F` runs grill_record_lint before any forge write, so an effort
7
+ # never carries a record that names nobody or holds no decision.
8
+ #
9
+ # A record passes in one of two shapes:
10
+ # 1. a waiver: the single line `waived: <reason>`, the reason not empty.
11
+ # 2. a confirmed record:
12
+ # - its first non-blank line starts `Grilled:` and names who was grilled
13
+ # (`Grilled: the maintainer, 2026-11-22, in session.`);
14
+ # - a `YYYY-MM-DD` date somewhere in the record;
15
+ # - at least 3 decisions as column-0 `1.` or `1)` items, or a link to the forge comment that
16
+ # holds them (`…/issues/<n>#issuecomment-<id>`). An indented item continues the one above.
17
+ # An unattended run that assumed the decisions writes `Grilled: <agent> (assumed)`; it passes the
18
+ # lint, and the word `assumed` stays in the record so a reader sees no conversation happened.
19
+ #
20
+ # Functions:
21
+ # grill_record_lint <text|-> rc 0 clean · 1 + reasons on stderr · 2 usage (no argument)
22
+ # grill_record_section <text> echo "## Grilling", a blank line, then the text (blank edges cut)
23
+ #
24
+ # bash 3.2 compatible; sourceable under zsh (awk does the parsing, no arrays).
25
+ # errors: strict — a validator: rc 1 on a record that is not one
26
+
27
+ GRILL_MIN_DECISIONS="${GRILL_MIN_DECISIONS:-3}"
28
+
29
+ # _grill_scan — read a record on stdin, print "<waiver 0|1|2> <grilled 0|1> <date 0|1> <decisions> <link 0|1>".
30
+ # waiver: 0 none, 1 a valid waiver, 2 `waived:` with no reason.
31
+ _grill_scan() {
32
+ tr -d '\r' | awk '
33
+ BEGIN { first = ""; waiver = 0; date = 0; dec = 0; link = 0; nonblank = 0 }
34
+ {
35
+ line = $0
36
+ if (line ~ /^[ \t]*$/) next
37
+ nonblank++
38
+ if (first == "") first = line
39
+ if (line ~ /[0-9][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]/) date = 1
40
+ if (line ~ /^[0-9]+[.)][ \t]+[^ \t]/) dec++
41
+ if (line ~ /\/issues\/[0-9]+#issuecomment-[0-9]+/) link = 1
42
+ }
43
+ END {
44
+ f = first; sub(/^[ \t]+/, "", f)
45
+ if (nonblank == 1 && tolower(f) ~ /^waived:/) {
46
+ r = f; sub(/^[^:]*:[ \t]*/, "", r)
47
+ waiver = (r == "") ? 2 : 1
48
+ }
49
+ grilled = (f ~ /^Grilled:[ \t]*[^ \t]/) ? 1 : 0
50
+ printf "%d %d %d %d %d\n", waiver, grilled, date, dec, link
51
+ }'
52
+ }
53
+
54
+ grill_record_lint() {
55
+ [ $# -ge 1 ] || { echo "grill_record_lint: usage: grill_record_lint <text|->" >&2; return 2; }
56
+ local scan waiver grilled date dec link reasons=""
57
+ if [ "$1" = "-" ]; then scan="$(_grill_scan)"
58
+ else scan="$(printf '%s\n' "$1" | _grill_scan)"; fi
59
+ read -r waiver grilled date dec link <<EOF_SCAN
60
+ $scan
61
+ EOF_SCAN
62
+ case "${waiver:-0}" in
63
+ 1) return 0 ;;
64
+ 2) reasons="'waived:' needs a reason after it" ;;
65
+ *)
66
+ [ "${grilled:-0}" = 1 ] || reasons="${reasons}the first line must start 'Grilled:' and name who was grilled
67
+ "
68
+ [ "${date:-0}" = 1 ] || reasons="${reasons}no YYYY-MM-DD date — say when the grill happened
69
+ "
70
+ if [ "${link:-0}" != 1 ] && [ "${dec:-0}" -lt "$GRILL_MIN_DECISIONS" ]; then
71
+ reasons="${reasons}${dec:-0} decision(s) — record at least $GRILL_MIN_DECISIONS as column-0 '1.' items, or link the comment that holds them
72
+ "
73
+ fi ;;
74
+ esac
75
+ [ -n "$reasons" ] || return 0
76
+ {
77
+ echo "✗ the Grilling record is not one (skills/kit-advisor/references/grill.md):"
78
+ printf '%s' "$reasons" | sed '/^$/d; s/^/ - /'
79
+ echo " (or write the single line 'waived: <reason>')"
80
+ } >&2
81
+ return 1
82
+ }
83
+
84
+ grill_record_section() {
85
+ echo "## Grilling"
86
+ echo
87
+ printf '%s\n' "${1:-}" | tr -d '\r' | awk 'NF { started = 1 } started { buf[++n] = $0 } END { while (n > 0 && buf[n] ~ /^[ \t]*$/) n--; for (i = 1; i <= n; i++) print buf[i] }'
88
+ }
@@ -50,7 +50,7 @@ handoff_read() {
50
50
  cat "$f"
51
51
  else
52
52
  echo "cckit: no resume-here handoff saved."
53
- echo "Run 'cckit sync' for the board, or save one with:"
53
+ echo "Run 'cckit status --board' for the board, or save one with:"
54
54
  echo " cckit handoff \"<what's pending, the next step, any PR/issue refs>\""
55
55
  fi
56
56
  }
@@ -281,6 +281,23 @@ EOF
281
281
  eq "a failed issue read is rc 1" "$rc" "1"
282
282
  has "a failed issue read names the issue" "$missing" "could not read issue #404 from o/r"
283
283
 
284
+ # ── --skills / --verbs: the worker's toolset, exactly as named (#582) ──────────────────────
285
+ : > "$GH_LOG"
286
+ tool_out="$(cd "$repo" && export PATH="$ghstub:$PATH" && ( set -eu; kit_brief 5 --skills kit-advisor --verbs 'effort start, cckit brief' ) 2>&1)"
287
+ has "toolset: the section is there" "$tool_out" "## Your toolset"
288
+ has "toolset: the skill is listed" "$tool_out" '- skill `kit-advisor`'
289
+ has "toolset: a two-word verb is listed" "$tool_out" '- verb `cckit effort start`'
290
+ has "toolset: a leading cckit is dropped" "$tool_out" '- verb `cckit brief`'
291
+ eq "toolset: lists exactly what was named" "$(printf '%s\n' "$tool_out" | grep -c '^- \(skill\|verb\) `')" "3"
292
+ has "toolset: the brief still renders" "$tool_out" "## Standing gotchas"
293
+ : > "$GH_LOG"
294
+ bad_out="$(cd "$repo" && export PATH="$ghstub:$PATH" && ( kit_brief 5 --skills kit-advisor,no-such-skill --verbs 'effort fly,frobnicate' ) 2>&1)"; rc=$?
295
+ eq "toolset: an unknown name is rc 2" "$rc" "2"
296
+ has "toolset: names the unknown skill" "$bad_out" "unknown skill 'no-such-skill'"
297
+ has "toolset: names the unknown sub-verb" "$bad_out" "unknown verb 'cckit effort fly'"
298
+ has "toolset: names the unknown verb" "$bad_out" "unknown verb 'cckit frobnicate'"
299
+ eq "toolset: refused before any forge read" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
300
+
284
301
  # ── the QA route ask appears only when a `qa` block is configured (#297) ───────────────────
285
302
  # `cckit qa open` reads a `QA route:` line out of the PR body; the brief is where the builder
286
303
  # is told to write it. With no review stack nothing reads the line, so the brief stays silent.
@@ -309,6 +326,18 @@ EOF
309
326
  has "no argument prints usage" "$out" "usage: cckit brief"
310
327
  out="$(kit_brief --llm 2>&1)"; rc=$?
311
328
  eq "a flag without an issue is rc 2" "$rc" "2"
329
+ out="$(kit_brief 5 --skills 2>&1)"; rc=$?
330
+ eq "--skills with no list is rc 2" "$rc" "2"
331
+ out="$(kit_brief 5 --bogus 2>&1)"; rc=$?
332
+ eq "an unknown flag is rc 2" "$rc" "2"
333
+ eq "verb_ok: an alias row counts" "$(kit_brief_verb_ok status && echo y)" "y"
334
+ eq "verb_ok: effort with no sub counts" "$(kit_brief_verb_ok effort && echo y)" "y"
335
+ eq "skill_ok: a path is never a skill" "$(kit_brief_skill_ok ../x || echo n)" "n"
336
+ # The sub-verbs a brief accepts are the ones the dispatcher routes.
337
+ usage_line="$(grep -o 'cckit effort <[a-z|]*>' "$dir/../../bin/cckit" | sed -n 1p)"
338
+ for s in $(printf '%s' "$KB_EFFORT_SUBS" | tr ' ' '\n'); do
339
+ has "effort sub-verb '$s' is in the dispatcher" "$usage_line" "$s"
340
+ done
312
341
 
313
342
  rm -rf "$tmp"
314
343
  if [ "$fail" -eq 0 ]; then echo "PASS($KB_TEST_INNER): kit-brief parsers + real-state lookups"; fi
@@ -24,6 +24,7 @@ fi
24
24
  _kb_dir="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)"
25
25
  # shellcheck source=/dev/null
26
26
  command -v kit_config_path >/dev/null 2>&1 || . "$_kb_dir/config-path.sh"
27
+ _KB_LIB="$_kb_dir"
27
28
  unset _kb_dir
28
29
 
29
30
  # ── pure parsers (no gh, no git; every one is unit-tested against fixture text) ─────────────────
@@ -214,6 +215,71 @@ _kb_rows() {
214
215
  done
215
216
  }
216
217
 
218
+ # ── the worker's toolset (#582): --skills / --verbs ─────────────────────────────────────────────
219
+
220
+ # The effort sub-verbs a brief may name as `effort <sub>`. Kept beside the dispatcher's own list
221
+ # in bin/cckit; kit-brief-test.sh fails when the two drift.
222
+ KB_EFFORT_SUBS="new sub retitle chain start pr close plan sprint review"
223
+
224
+ # kit_brief_skill_ok <name> [root] — rc 0 when a skill of that name ships: the project's
225
+ # `.claude/skills/<name>/SKILL.md`, its `skills/<name>/SKILL.md`, or the kit's own skills/.
226
+ kit_brief_skill_ok() {
227
+ local s="$1" root="${2:-.}" kit
228
+ case "$s" in ''|*/*|.*) return 1 ;; esac
229
+ kit="${CCKIT_ROOT:-$_KB_LIB/../..}"
230
+ [ -f "$root/.claude/skills/$s/SKILL.md" ] || [ -f "$root/skills/$s/SKILL.md" ] || [ -f "$kit/skills/$s/SKILL.md" ]
231
+ }
232
+
233
+ # kit_brief_verb_ok <verb words> — rc 0 when the first word is a row of verbs.tsv (a verb or an
234
+ # alias) and, for `effort`, the second word is one of its sub-verbs.
235
+ kit_brief_verb_ok() {
236
+ local v="$1" first rest tsv="$_KB_LIB/verbs.tsv"
237
+ first="${v%% *}"; rest=""
238
+ [ "$first" = "$v" ] || rest="${v#* }"; rest="${rest%% *}"
239
+ [ -n "$first" ] && [ -f "$tsv" ] || return 1
240
+ awk -F'\t' -v n="$first" '$1 == n { f = 1 } END { exit !f }' "$tsv" || return 1
241
+ if [ "$first" = "effort" ] && [ -n "$rest" ]; then
242
+ case " $KB_EFFORT_SUBS " in *" $rest "*) return 0 ;; *) return 1 ;; esac
243
+ fi
244
+ return 0
245
+ }
246
+
247
+ # kit_brief_toolset <skills-csv> <verbs-csv> [root] — print the `## Your toolset` section listing
248
+ # exactly the named skills and verbs, in the order given. A name that does not resolve is an error
249
+ # (rc 2, every unknown name on stderr), so a brief never hands a worker a tool that is not there.
250
+ kit_brief_toolset() {
251
+ local skills="$1" verbs="$2" root="${3:-.}" bad=0 item rest
252
+ rest="$skills"
253
+ while [ -n "$rest" ]; do
254
+ item="${rest%%,*}"; [ "$item" = "$rest" ] && rest="" || rest="${rest#*,}"
255
+ item="$(printf '%s' "$item" | sed 's/^ *//; s/ *$//')"; [ -n "$item" ] || continue
256
+ kit_brief_skill_ok "$item" "$root" || { echo "cckit brief: unknown skill '$item'" >&2; bad=1; }
257
+ done
258
+ rest="$verbs"
259
+ while [ -n "$rest" ]; do
260
+ item="${rest%%,*}"; [ "$item" = "$rest" ] && rest="" || rest="${rest#*,}"
261
+ item="$(printf '%s' "$item" | sed 's/^ *//; s/ *$//; s/^cckit *//')"; [ -n "$item" ] || continue
262
+ kit_brief_verb_ok "$item" || { echo "cckit brief: unknown verb 'cckit $item'" >&2; bad=1; }
263
+ done
264
+ [ "$bad" -eq 0 ] || return 2
265
+ echo "## Your toolset"
266
+ echo
267
+ echo "Use these and no others. A step they cannot do is a defect to report, not a reason to hand-roll \`git\` or \`gh\`."
268
+ echo
269
+ rest="$skills"
270
+ while [ -n "$rest" ]; do
271
+ item="${rest%%,*}"; [ "$item" = "$rest" ] && rest="" || rest="${rest#*,}"
272
+ item="$(printf '%s' "$item" | sed 's/^ *//; s/ *$//')"; [ -n "$item" ] || continue
273
+ printf -- '- skill `%s`\n' "$item"
274
+ done
275
+ rest="$verbs"
276
+ while [ -n "$rest" ]; do
277
+ item="${rest%%,*}"; [ "$item" = "$rest" ] && rest="" || rest="${rest#*,}"
278
+ item="$(printf '%s' "$item" | sed 's/^ *//; s/ *$//; s/^cckit *//')"; [ -n "$item" ] || continue
279
+ printf -- '- verb `cckit %s`\n' "$item"
280
+ done
281
+ }
282
+
217
283
  # ── the verb ───────────────────────────────────────────────────────────────────────────────────
218
284
 
219
285
  # kit_brief <issue> — print the delegation brief for an issue as markdown. strict about its one
@@ -222,15 +288,29 @@ _kb_rows() {
222
288
  # a brief that silently omits a section is the failure mode this verb exists to remove.
223
289
  kit_brief() {
224
290
  local n="${1:-}" root base repo body title state labels foragents files files_from wt wtpath wtbranch
225
- local seed gotchas prose libdir row f gate qaroute
291
+ local seed gotchas prose libdir row f gate qaroute want_skills="" want_verbs="" toolset=""
226
292
  case "$n" in
227
- ''|--*) echo "usage: cckit brief <issue>" >&2; return 2 ;;
293
+ ''|--*) echo "usage: cckit brief <issue> [--skills a,b] [--verbs 'x,effort start']" >&2; return 2 ;;
228
294
  esac
295
+ shift
296
+ while [ $# -gt 0 ]; do
297
+ case "$1" in
298
+ --skills) [ $# -ge 2 ] || { echo "cckit brief: --skills needs a list" >&2; return 2; }; want_skills="$2"; shift 2 ;;
299
+ --skills=*) want_skills="${1#--skills=}"; shift ;;
300
+ --verbs) [ $# -ge 2 ] || { echo "cckit brief: --verbs needs a list" >&2; return 2; }; want_verbs="$2"; shift 2 ;;
301
+ --verbs=*) want_verbs="${1#--verbs=}"; shift ;;
302
+ *) echo "cckit brief: unknown argument '$1'" >&2; return 2 ;;
303
+ esac
304
+ done
229
305
  n="${n#\#}"
306
+ root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
307
+ # The toolset is checked before any forge read, so a typo costs nothing and writes nothing.
308
+ if [ -n "$want_skills$want_verbs" ]; then
309
+ toolset="$(kit_brief_toolset "$want_skills" "$want_verbs" "$root")" || return 2
310
+ fi
230
311
  forge_need brief || return 1
231
312
  command -v jq >/dev/null 2>&1 || { echo "cckit brief: jq is required" >&2; return 1; }
232
313
 
233
- root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
234
314
  base="${KIT_BASE_BRANCH:-main}"
235
315
  repo="${KIT_REPO:-}"
236
316
 
@@ -267,6 +347,11 @@ kit_brief() {
267
347
  printf '\n- issue: `#%s` · %s%s\n' "$n" "${state:-unknown}" "${labels:+ · $labels}"
268
348
  [ -n "$repo" ] && printf -- '- repo: `%s` · base branch `%s`\n' "$repo" "$base"
269
349
 
350
+ if [ -n "$toolset" ]; then
351
+ echo
352
+ printf '%s\n' "$toolset"
353
+ fi
354
+
270
355
  # ── where the work happens
271
356
  wt="$(kit_brief_worktree "$n")"
272
357
  wtpath="${wt%% *}"; wtbranch="${wt##* }"
@@ -371,15 +456,15 @@ EOF
371
456
  echo "| --- | --- | --- |"
372
457
  printf '%s\n' "$shown_owned" | grep . || true
373
458
  printf '%s\n' "$shown_src" | grep . || true
374
- [ "$n_over" -gt 0 ] && printf -- '\n_+%s more helper(s) these files source — `cckit lib` lists them._\n' "$n_over"
459
+ [ "$n_over" -gt 0 ] && printf -- '\n_+%s more helper(s) these files source — `cckit agent lib` lists them._\n' "$n_over"
375
460
  else
376
461
  echo "_None of the issue's files are helpers or source one._"
377
462
  fi
378
463
  echo
379
- printf -- '_Full catalog: `cckit lib` (%s helpers). Do not reimplement what it already lists._\n' \
464
+ printf -- '_Full catalog: `cckit agent lib` (%s helpers). Do not reimplement what it already lists._\n' \
380
465
  "$(kit_lib_files "$libdir" | grep -c . || true)"
381
466
  else
382
- echo "_No helper catalog here — `cckit lib` is unavailable in this project._"
467
+ echo "_No helper catalog here — `cckit agent lib` is unavailable in this project._"
383
468
  fi
384
469
 
385
470
  # ── standing gotchas, from the project's own rule
@@ -159,7 +159,7 @@ if [ -n "${KL_TEST_INNER:-}" ]; then
159
159
  eq "empty exits 0" "$erc" "0"
160
160
  has "empty has a graceful state" "$eout" 'no `.sh` helpers'
161
161
 
162
- eq "help lists the flags" "$(KIT_LIB_DIR="$fix" kit_lib --help | grep -c '^cckit lib')" "5"
162
+ eq "help lists the flags" "$(KIT_LIB_DIR="$fix" kit_lib --help | grep -c '^cckit agent lib')" "5"
163
163
 
164
164
  if command -v jq >/dev/null 2>&1; then
165
165
  llm="$(KIT_LIB_DIR="$fix" CCKIT_OUTPUT=json kit_lib --llm)"
@@ -10,11 +10,11 @@
10
10
  # functions its PUBLIC functions (`_`-prefixed names are private by convention, so they are cut)
11
11
  # purpose the file's own header sentence — derived, never invented
12
12
  #
13
- # cckit lib the helper catalog as a markdown table
14
- # cckit lib --llm TOON rows {file,errors,functions,purpose} (JSON fallback)
15
- # cckit lib --all include the *-test.sh runners (excluded by default)
16
- # cckit lib --reasons every file's failure reason, not only the `mixed` ones
17
- # cckit lib --root <dir> catalog <dir>'s library instead of the resolved one
13
+ # cckit agent lib the helper catalog as a markdown table
14
+ # cckit agent lib --json TOON rows {file,errors,functions,purpose} (JSON fallback)
15
+ # cckit agent lib --all include the *-test.sh runners (excluded by default)
16
+ # cckit agent lib --reasons every file's failure reason, not only the `mixed` ones
17
+ # cckit agent lib --root <dir> catalog <dir>'s library instead of the resolved one
18
18
  #
19
19
  # Filesystem-only — no network, no gh; jq only for --llm (TOON/JSON). Runs in any project cckit is
20
20
  # installed in: it catalogs that project's own scripts/lib when it has one, otherwise the cckit
@@ -216,7 +216,7 @@ kit_lib_dir() {
216
216
  # ── the verb ──────────────────────────────────────────────────────────────────────────────────
217
217
 
218
218
  # _kl_usage — the usage block, read back from this file's own header (one source of truth).
219
- _kl_usage() { sed -n 's/^# \(cckit lib.*\)$/\1/p' "${BASH_SOURCE[0]:-$0}"; }
219
+ _kl_usage() { sed -n 's/^# \(cckit agent lib.*\)$/\1/p' "${BASH_SOURCE[0]:-$0}"; }
220
220
 
221
221
  # _kl_err — structured error for --llm mode (mirrors the other verbs' failure shape).
222
222
  _kl_err() { printf '{"error":"lib: %s"}\n' "$1"; }
@@ -226,7 +226,7 @@ kit_lib() {
226
226
  local out="${CCKIT_OUTPUT:-human}" root="" all=0 reasons=0
227
227
  while [ "$#" -gt 0 ]; do
228
228
  case "$1" in
229
- --llm|--output=json) out="json"; shift ;;
229
+ --json|--llm|--output=json) out="json"; shift ;;
230
230
  --all) all=1; shift ;;
231
231
  --reasons) reasons=1; shift ;;
232
232
  --root) # Validate BEFORE shifting: `shift 2` on a single remaining argument aborts bash
@@ -56,7 +56,7 @@ msg_send() {
56
56
  local steer=0
57
57
  [ "${1:-}" = "--steer" ] && { steer=1; shift; }
58
58
  local text="$*"
59
- [ -n "$target" ] && [ -n "$text" ] || { echo 'msg_send: usage: cckit msg send <branch|all|project:branch|project:all> [--steer] "<text>"' >&2; return 1; }
59
+ [ -n "$target" ] && [ -n "$text" ] || { echo 'msg_send: usage: cckit agent msg send <branch|all|project:branch|project:all> [--steer] "<text>"' >&2; return 1; }
60
60
  _msg_parse "$target" || { echo "msg_send: bad target '$target'" >&2; return 1; }
61
61
  local from_proj from_branch
62
62
  from_proj="$(_msg_proj)"; from_branch="$(_msg_branch)"; from_branch="${from_branch:-unknown}"
@@ -64,7 +64,7 @@ msg_send() {
64
64
  # A typo'd target would silently create a dead mailbox (hcom hard-fails here; we warn) — flag a
65
65
  # first-time mailbox so a misaddressed steer doesn't just vanish.
66
66
  [ -d "$(dirname "$box")" ] || [ "$_MSG_BOX" = "all" ] \
67
- || echo " ⚠ new mailbox $_MSG_PROJ:$_MSG_BOX — no session has mail here yet; check the target if you expected one (cckit msg list)" >&2
67
+ || echo " ⚠ new mailbox $_MSG_PROJ:$_MSG_BOX — no session has mail here yet; check the target if you expected one (cckit agent msg list)" >&2
68
68
  mkdir -p "$box" || return 1
69
69
  local kind="note"; [ "$steer" = 1 ] && kind="steer"
70
70
  # epoch-$$ alone collides for two sends in the same second from one shell — the second message
@@ -204,7 +204,7 @@ EOF_UNREAD
204
204
  fi
205
205
  [ "$count" -gt 0 ] || return 0
206
206
 
207
- local msg="SESSION MAIL (cckit msg): a parallel session sent you the message(s) below. If one is kind: steer, act on it BEFORE continuing your current plan.
207
+ local msg="SESSION MAIL (cckit agent msg): a parallel session sent you the message(s) below. If one is kind: steer, act on it BEFORE continuing your current plan.
208
208
  $body"
209
209
  local esc; esc="$(printf '%s' "$msg" | _msg_json_escape)"
210
210
  if [ "$event" = "Stop" ]; then
@@ -168,7 +168,7 @@ status_prs_classify() {
168
168
  elif ($ai == 1 and (($p.ai_review // false) | not)) then "ai-review"
169
169
  elif (($p.approvals // 0) == 0) then "review"
170
170
  else "ready" end) as $v |
171
- (if $v == "conflict" then "merge state is CONFLICTING — rebase onto the base"
171
+ (if $v == "conflict" then "merge state is CONFLICTING — merge the base into the branch"
172
172
  elif $v == "checks" then "a required check is failing"
173
173
  elif $v == "draft" then "still a draft"
174
174
  elif $v == "wait" then (if ($p.mergeable // "") == "UNKNOWN" and ($p.checks // "NONE") != "PENDING"
@@ -71,6 +71,23 @@ if [ -n "${KTO_TEST_INNER:-}" ]; then
71
71
  eq "titleStyle issue-title → the issue title verbatim" \
72
72
  "$(KIT_PR_TITLE_STYLE=issue-title kto_pr_title '[Effort 182] 1 · Enforce it' 'ci: x' 'kind:task')" \
73
73
  "[Effort 182] 1 · Enforce it"
74
+ # The trailing token (E546.1), when the issue number is given
75
+ eq "standalone issue → [#N]" \
76
+ "$(kto_pr_title 'mail hook goes silent' '' 'bug' 209)" \
77
+ "fix: mail hook goes silent [#209]"
78
+ eq "new sub title → [E<n>.<s>]" \
79
+ "$(kto_pr_title '[E546.1] One naming convention' '' 'kind:feat' 567)" \
80
+ "feat: One naming convention [E546.1]"
81
+ eq "legacy sub title → [E<n>.<s>]" \
82
+ "$(kto_pr_title '[Effort 182] 2 · Publish to npm' 'ci: publish via OIDC' 'kind:task' 184)" \
83
+ "ci: publish via OIDC [E182.2]"
84
+ eq "a summary that carries a token keeps it" \
85
+ "$(kto_pr_title 'x' 'fix(start): keep it [#12]' 'kind:task' 12)" \
86
+ "fix(start): keep it [#12]"
87
+ eq "issue-title style appends nothing" \
88
+ "$(KIT_PR_TITLE_STYLE=issue-title kto_pr_title 'Enforce it' '' 'kind:task' 12)" \
89
+ "Enforce it"
90
+ if naming_title_lint pr "$(kto_pr_title '[E546.1] One naming convention' '' 'kind:feat' 567)" 2>/dev/null; then :; else eq "generated PR title passes the naming lint" "no" "yes"; fi
74
91
  eq "titleStyle conventional (explicit) → derive" \
75
92
  "$(KIT_PR_TITLE_STYLE=conventional kto_pr_title 'mail hook goes silent' '' 'bug')" \
76
93
  "fix: mail hook goes silent"
@@ -22,7 +22,7 @@
22
22
  # kto_closing_issue_numbers <pr-num> echo the issue #s a merged PR closes
23
23
  # kto_task_pr <num> <summary> [commit-msg] [--base <branch>] commit+push+open PR (board → In Review)
24
24
  # kto_task_pr_merge [pr-num] [--squash|--merge|--rebase] merge (squash default) + close issues + GC + update the PR base; refuses an effort/* head
25
- # kto_task_new <title> <role> <kind> <prio> [ms] [plan] [blocked] <body> create issue + board fields (ms may be empty)
25
+ # kto_task_new <title> <role> <kind> <prio> [ms] [plan] [blocked] <body> lint the title, create issue + board fields (ms may be empty)
26
26
  # kto_task_close <num> <summary> [pr-num] [--reason R] [--duplicate-of N] [--superseded-by N] close + reason + board → Done
27
27
  # errors: mixed — git/gh ops propagate; board + label side effects are best-effort
28
28
 
@@ -68,6 +68,18 @@ if ! type kit_kind_commit_type >/dev/null 2>&1; then
68
68
  fi
69
69
  type cckit_board_skipped >/dev/null 2>&1 || cckit_board_skipped() { return 1; }
70
70
 
71
+ # The one title convention (naming.sh, E546.1): kto_task_new lints the issue title and kto_task_pr
72
+ # the PR title before any forge write; kto_pr_title strips issue prefixes and appends the token.
73
+ if ! type naming_title_lint >/dev/null 2>&1; then
74
+ if [ -n "${BASH_SOURCE:-}" ]; then _kto_self="${BASH_SOURCE[0]}"
75
+ elif [ -n "${ZSH_VERSION:-}" ]; then eval '_kto_self="${(%):-%x}"'
76
+ else _kto_self="$0"; fi
77
+ _kto_self="$(cd "$(dirname "$_kto_self")" 2>/dev/null && pwd)/naming.sh"
78
+ # shellcheck source=naming.sh
79
+ [ -f "$_kto_self" ] && . "$_kto_self"
80
+ unset _kto_self
81
+ fi
82
+
71
83
  kto_repo() {
72
84
  printf '%s' "${KIT_TASK_REPO:-${KIT_REPO:-}}"
73
85
  }
@@ -109,13 +121,34 @@ kto_labels_kind() {
109
121
  # Compose the PR title as a Conventional Commit subject. Because PRs are squash-merged, this title
110
122
  # becomes the single commit release-please reads to pick the next version — a non-conventional title
111
123
  # under-bumps silently, and the commitlint gate (.github/workflows/commitlint.yml) now rejects it.
112
- # Args: <raw-issue-title> <summary> <labels-csv>
124
+ # Args: <raw-issue-title> <summary> <labels-csv> [<issue-num>]
113
125
  # 1. An author <summary> that is ALREADY a conventional subject wins — the author knows the change's
114
126
  # true type (e.g. a kind:task that is really a fix). Validated by the shared commitlint.sh.
115
127
  # 2. Otherwise derive the type from the kind:/bug label (kind:task, the default, → feat) and strip
116
- # the "[Effort N] M · " / leading "[Tag] " noise from the issue title.
128
+ # the issue title's prefix, new ([E<n>.<s>] ) or legacy ([Effort N] M · ), and a leading [Tag].
129
+ # 3. With <issue-num>, the title ends in the work's token (rules/naming-and-ids.md) unless it
130
+ # already does: [E<n>.<s>] when the issue is a sub, [E<n>] when it is an effort, else [#<num>].
117
131
  # Network-free (covered by the self-test). Output always passes commitlint_check.
118
132
  kto_pr_title() {
133
+ local raw="${1:-}" summary="${2:-}" labels="${3:-}" num="${4:-}" t
134
+ t="$(_kto_pr_title_subject "$raw" "$summary" "$labels")" || return 1
135
+ if [ -n "$num" ] && [ "${KIT_PR_TITLE_STYLE:-conventional}" != "issue-title" ]; then
136
+ t="$(_kto_pr_title_token "$t" "$raw" "$num")"
137
+ fi
138
+ printf '%s' "$t"
139
+ }
140
+
141
+ # _kto_pr_title_token <title> <raw-issue-title> <num> — <title> with the work's trailing token.
142
+ _kto_pr_title_token() {
143
+ local t="$1" raw="$2" num="${3#\#}" tok=""
144
+ if grep -qE '\[(E[0-9]+(\.[0-9]+)?|#[0-9]+|share-[0-9]+)\][[:space:]]*$' <<<"$t"; then printf '%s' "$t"; return 0; fi
145
+ if type naming_title_token >/dev/null 2>&1; then tok="$(naming_title_token "$raw" 2>/dev/null || true)"; fi
146
+ [ -n "$tok" ] || tok="#$num"
147
+ printf '%s [%s]' "$t" "$tok"
148
+ }
149
+
150
+ # _kto_pr_title_subject <raw-issue-title> <summary> <labels-csv> — steps 1 and 2 of kto_pr_title.
151
+ _kto_pr_title_subject() {
119
152
  local raw="${1:-}" summary="${2:-}" labels="${3:-}" kind ctype desc
120
153
  # pr.titleStyle = issue-title (KIT_PR_TITLE_STYLE): the PR title IS the issue title, verbatim — for
121
154
  # repos whose convention is "PR title = exact issue title" and that run no commitlint gate.
@@ -152,10 +185,12 @@ kto_pr_title() {
152
185
  esac
153
186
  fi
154
187
  case ",$labels," in *,bug,*) ctype=fix ;; esac # a plain `bug` label → fix
155
- # 3) Strip "[Effort N] M · " (the "· " consumed here as a literal — byte-wise match is portable
156
- # across BSD/GNU sed + locales; a negated class over the multibyte middot is not) and then a
157
- # leading "[Tag] " (e.g. [Core]). Order matters: eat the separator before the next tag's "[".
188
+ # 3) Strip "[E<n>.<s>] " / "[E<n>] " and the legacy "[Effort N] M · " (the "· " consumed here as
189
+ # a literal — byte-wise match is portable across BSD/GNU sed + locales; a negated class over the
190
+ # multibyte middot is not), then a leading "[Tag] " (e.g. [Core]). Order matters: eat the
191
+ # separator before the next tag's "[".
158
192
  desc="$(printf '%s' "$raw" | sed -E \
193
+ -e 's/^\[E[0-9]+(\.[0-9]+)?\] +//' \
159
194
  -e 's/^\[Effort[^]]*\] +[0-9]+ +· +//' \
160
195
  -e 's/^\[[^]]+\] +//' \
161
196
  -e 's/^[[:space:]]+//')"
@@ -346,7 +381,12 @@ kto_task_pr() {
346
381
  fi
347
382
  role="$(kto_labels_role "$labels")"
348
383
  # Conventional Commit PR title (squash-merge commit release-please reads + the commitlint gate).
349
- local pr_title; pr_title="$(kto_pr_title "$title" "$summary" "$labels")"
384
+ local pr_title; pr_title="$(kto_pr_title "$title" "$summary" "$labels" "$num")"
385
+ # The naming rule (E546.1) before the commit, the push or the PR: a Conventional Commit subject
386
+ # ending in the work's token. Refused here, nothing is written.
387
+ if type naming_title_lint >/dev/null 2>&1; then
388
+ naming_title_lint pr "$pr_title" || { echo "✗ kto_task_pr: the PR title breaks the naming rule — pass a summary of the form 'type(scope): subject'" >&2; return 1; }
389
+ fi
350
390
  [[ -z "$commit_msg" ]] && commit_msg="$pr_title"
351
391
 
352
392
  # TRACKED changes only: `git add -A` would sweep an untracked .env.local (copied into every worktree)
@@ -382,7 +422,7 @@ kto_task_pr() {
382
422
  pr_num="$(basename "$url")"
383
423
  pr_node=$(forge_rest "repos/$repo/pulls/$pr_num" --jq .node_id 2>/dev/null)
384
424
  if [[ -n "$pr_node" ]]; then
385
- item=$(project_add_item "$pr_node" 2>/dev/null || true)
425
+ item=$(project_add_item "$pr_node" "$repo" "$pr_num" PullRequest 2>/dev/null || true)
386
426
  if [[ -n "$item" ]]; then
387
427
  role_opt="$(_kto_role_option_for_slug "$role")"
388
428
  [[ -n "$role_opt" ]] && project_set_single_select "$item" "$ROLE_FIELD_ID" "$role_opt" 2>/dev/null || true
@@ -395,7 +435,7 @@ kto_task_pr() {
395
435
  fi
396
436
  }
397
437
 
398
- # kit task pr-merge — merge a PR (squash by default; --merge or --rebase), rebase-fix conflicts onto
438
+ # kit task pr-merge — merge a PR (squash by default; --merge or --rebase), merge-fix conflicts from
399
439
  # the PR's base first, close its linked issues (GitHub native auto-close only fires on the default
400
440
  # branch), then clean up the PR's head branch + worktree and bring the PR's base up to date.
401
441
  # Args: [<pr-num>] [--squash|--merge|--rebase] (the PR defaults to the open PR for the current branch)
@@ -462,22 +502,23 @@ kto_task_pr_merge() {
462
502
  fi
463
503
  fi
464
504
 
465
- # Branches that are never rebased, force-pushed or deleted here: the repo base, the PR's base
466
- # (it may be an effort branch), and the release branches (#366).
505
+ # Branches that are never merged into, pushed to or deleted here: the repo base, the PR's base
506
+ # (it may be an effort branch), and the release branches (#366). A pushed branch is brought onto
507
+ # its base by merge, never by rebase, so no push here needs --force (#592).
467
508
  _kto_protected() { case "$1" in "$base"|"$pr_base"|main|master|develop|HEAD) return 0 ;; esac; return 1; }
468
509
 
469
510
  if [[ "$merge_state" == "CONFLICTING" ]]; then
470
511
  if [[ "$branch" != "$head" ]] || _kto_protected "$branch"; then
471
- echo "✗ PR #$pr_num conflicts — rebase $head onto $pr_base from its own worktree (not from $branch)" >&2; return 1
512
+ echo "✗ PR #$pr_num conflicts — merge origin/$pr_base into $head from its own worktree (not from $branch)" >&2; return 1
472
513
  fi
473
- echo "→ Conflicts detected — rebasing onto $pr_base..."
514
+ echo "→ Conflicts detected — merging origin/$pr_base into $head..."
474
515
  git fetch origin "$pr_base"
475
- if git rebase "origin/$pr_base"; then
476
- git push --force-with-lease origin "$head"
477
- echo "✓ Rebased and pushed — re-checking mergeability..."
516
+ if git merge --no-edit "origin/$pr_base"; then
517
+ git push origin "$head"
518
+ echo "✓ Merged $pr_base in and pushed — re-checking mergeability..."
478
519
  else
479
- echo "✗ Rebase had conflicts that need manual resolution — resolve, then run cckit merge again" >&2
480
- git rebase --abort 2>/dev/null || true
520
+ echo "✗ Merge had conflicts that need manual resolution — from this branch's worktree run: git merge origin/$pr_base, resolve, commit, push, then run cckit merge again" >&2
521
+ git merge --abort 2>/dev/null || true
481
522
  return 1
482
523
  fi
483
524
  fi
@@ -622,19 +663,25 @@ EOF
622
663
  }
623
664
 
624
665
  # kit task new — create a GitHub issue with labels + milestone, add it to the board, set Role +
625
- # Status(Todo) + Plan Link. Inputs are passed (the caller does the AskUserQuestion). No invented
666
+ # Status (Backlog when no milestone is named and the board has that option, else Todo) + Plan Link. Inputs are passed (the caller does the AskUserQuestion). No invented
626
667
  # values: a label the repo does not have is dropped with a warning, never created, and the issue is
627
668
  # still filed (#387). Non-zero only when the issue itself was not created.
628
669
  # Args: <title> <role-display-or-slug> <kind> <priority> [milestone|""] [plan-link] [blocked-by] <body>
629
670
  kto_task_new() {
630
671
  local title="${1:-}" role="${2:-}" kind="${3:-}" prio="${4:-}" milestone="${5:-}" plan="${6:-}" blocked="${7:-}" body_user="${8:-}"
631
- local repo role_slug labels body url num node item role_opt
672
+ local repo role_slug labels body url num node item role_opt status_opt
632
673
  repo="$(kto_repo)"
633
674
  # Milestone is optional: a repo with no milestones (cckit itself) must still be able to file an
634
675
  # issue through the verb, or agents fall back to raw `gh issue create` and the board drops it.
635
676
  [[ -n "$title" && -n "$role" && -n "$kind" && -n "$prio" ]] || {
636
677
  echo "✗ kto_task_new: title, role, kind, priority are required" >&2; return 1; }
637
678
 
679
+ # The naming rule (E546.1): a standalone issue is a plain outcome of at most six words, no prefix.
680
+ # Checked before any forge read or write; multi-part work is `cckit effort new`.
681
+ if type naming_title_lint >/dev/null 2>&1; then
682
+ naming_title_lint issue "$title" || { echo "✗ kto_task_new: fix the title and retry — nothing was filed" >&2; return 1; }
683
+ fi
684
+
638
685
  role_slug="$(printf '%s' "$role" | tr 'A-Z ' 'a-z-')"
639
686
  labels="kind:${kind},priority:${prio},role:${role_slug}"
640
687
  body="$(kto_compose_issue_body "$body_user" "$plan" "$blocked" "$role_slug")"
@@ -647,14 +694,18 @@ kto_task_new() {
647
694
  if kto_board_enabled && type load_project_ids >/dev/null 2>&1 && load_project_ids 2>/dev/null; then
648
695
  node=$(forge_rest "repos/$repo/issues/$num" --jq .node_id 2>/dev/null)
649
696
  item=""
650
- [[ -n "$node" ]] && item=$(project_add_item "$node" 2>/dev/null || true)
697
+ [[ -n "$node" ]] && item=$(project_add_item "$node" "$repo" "$num" Issue 2>/dev/null || true)
651
698
  # Loud, not silent: an issue missing from the board is the failure this verb exists to prevent.
652
699
  [[ -z "$item" ]] && echo "⚠ #$num was created but NOT added to the board — add it by hand" >&2
653
700
  if [[ -n "$node" ]]; then
654
701
  if [[ -n "$item" ]]; then
655
702
  role_opt="$(_kto_role_option_for_slug "$role_slug")"
656
703
  [[ -n "$role_opt" ]] && project_set_single_select "$item" "$ROLE_FIELD_ID" "$role_opt" 2>/dev/null || true
657
- [[ -n "${STATUS_OPT_TODO:-}" ]] && project_set_single_select "$item" "$STATUS_FIELD_ID" "$STATUS_OPT_TODO" 2>/dev/null || true
704
+ # No sprint (milestone) named: the issue waits in the Backlog column, so it is not loose
705
+ # (E546.2). A board without a Backlog option keeps Todo.
706
+ status_opt="${STATUS_OPT_TODO:-}"
707
+ [[ -z "$milestone" && -n "${STATUS_OPT_BACKLOG:-}" ]] && status_opt="$STATUS_OPT_BACKLOG"
708
+ [[ -n "$status_opt" ]] && project_set_single_select "$item" "$STATUS_FIELD_ID" "$status_opt" 2>/dev/null || true
658
709
  [[ -n "$plan" && -n "${PLAN_LINK_FIELD_ID:-}" ]] && project_set_text "$item" "$PLAN_LINK_FIELD_ID" "$plan" 2>/dev/null || true
659
710
  fi
660
711
  fi
@@ -80,5 +80,23 @@ t "create fails: rc non-zero" "$([ "$rc" -ne 0 ] && echo
80
80
  t "create fails: prints nothing on stdout" "$(wc -c < "$tmp/out" | tr -d ' ')" "0"
81
81
  t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
82
82
 
83
+ # ── the board Status (E546.2): no milestone -> Backlog when the board has it, else Todo ──────────────
84
+ have kind:feat priority:p2 role:backend
85
+ export KIT_PROJECTS_V2="true"
86
+ load_project_ids() { STATUS_FIELD_ID="SF"; STATUS_OPT_TODO="OPT_TODO"; return 0; }
87
+ project_add_item() { echo "ITEM"; }
88
+ project_set_single_select() { echo "set $1 $2 $3" >> "$tmp/board"; }
89
+ : > "$tmp/board"; fresh
90
+ STATUS_OPT_BACKLOG="OPT_BACKLOG" kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"
91
+ tc "$tmp/board" '^set ITEM SF OPT_BACKLOG$' "no milestone, a Backlog option: Status is Backlog"
92
+ tn "$tmp/board" 'OPT_TODO' "no milestone, a Backlog option: Status is not Todo"
93
+ : > "$tmp/board"; fresh
94
+ STATUS_OPT_BACKLOG="OPT_BACKLOG" kto_task_new "Test" backend feat p2 "M1" "" "" x >"$tmp/out" 2>"$tmp/err"
95
+ tc "$tmp/board" '^set ITEM SF OPT_TODO$' "a milestone named: Status is Todo"
96
+ : > "$tmp/board"; fresh
97
+ kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"
98
+ tc "$tmp/board" '^set ITEM SF OPT_TODO$' "no Backlog option on the board: Status stays Todo"
99
+ export KIT_PROJECTS_V2="false"
100
+
83
101
  [ "$fail" -eq 0 ] && echo "kto-task-new: all passed" || echo "kto-task-new: FAILURES"
84
102
  exit "$fail"