@jeiemgi/cckit 0.9.0 → 0.10.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 +169 -21
- package/README.md +491 -35
- package/SECURITY.md +5 -0
- package/bin/cckit +182 -17
- package/cckit.config.json +1 -1
- package/commands/kit-doctor.md +13 -5
- package/commands/kit-export-project.md +0 -2
- package/commands/kit-export-training.md +6 -9
- package/commands/kit-init.md +43 -13
- package/commands/kit-routines.md +1 -1
- package/commands/kit-update.md +11 -6
- package/databases/supabase/guide.html +106 -0
- package/databases/supabase/nextjs/lib/supabase/client.ts +9 -0
- package/databases/supabase/nextjs/lib/supabase/server.ts +29 -0
- package/databases/supabase.json +70 -0
- package/integrations/emil-design-eng.json +41 -0
- package/integrations/graft.json +81 -0
- package/integrations/impeccable.json +42 -0
- package/integrations/integration.schema.json +215 -0
- package/integrations/lavish.json +43 -0
- package/integrations/mempalace.json +28 -0
- package/integrations/mlx-lm.json +32 -0
- package/integrations/web-design-guidelines.json +42 -0
- package/kit.config.schema.json +183 -5
- package/package.json +4 -1
- package/profiles/automation.json +7 -1
- package/profiles/content.json +10 -2
- package/profiles/marketing.json +57 -0
- package/profiles/minimal.json +7 -1
- package/profiles/research.json +7 -1
- package/profiles/software.json +7 -1
- package/recipes/nextjs-shadcn.json +49 -0
- package/scripts/agent-skills-external.txt +45 -0
- package/scripts/agent-skills-lint-test.sh +131 -0
- package/scripts/agent-skills-lint.sh +115 -0
- package/scripts/agent-template-lint-test.sh +42 -0
- package/scripts/agent-template-lint.sh +58 -0
- package/scripts/annotate-setup.sh +1 -1
- package/scripts/autopilot-run-test.sh +338 -0
- package/scripts/autopilot-run.sh +448 -0
- package/scripts/autopilot-test.sh +8 -0
- package/scripts/autopilot.sh +10 -1
- package/scripts/benchmark/benchmark-test.sh +85 -0
- package/scripts/benchmark/checkpoint-test.sh +314 -0
- package/scripts/benchmark/checkpoint.sh +408 -0
- package/scripts/benchmark/lib/model.sh +31 -6
- package/scripts/benchmark/report.sh +17 -2
- package/scripts/benchmark/run-quality.sh +36 -10
- package/scripts/benchmark/verb-timings-test.sh +124 -0
- package/scripts/benchmark/verb-timings.sh +149 -0
- package/scripts/check.sh +29 -19
- package/scripts/content-skills-test.sh +144 -0
- package/scripts/copilot-loop-test.sh +25 -0
- package/scripts/database-supabase-test.sh +121 -0
- package/scripts/docs-marketing-words-test.sh +73 -0
- package/scripts/docs-record-tables-test.sh +72 -0
- package/scripts/hook-adapter-test.sh +193 -0
- package/scripts/init-content-test.sh +225 -0
- package/scripts/init-guided-test.sh +474 -0
- package/scripts/init-recipes-test.sh +104 -0
- package/scripts/init-upgrade-test.sh +341 -2
- package/scripts/init.sh +746 -95
- package/scripts/instruction-budget-baseline.txt +8 -0
- package/scripts/instruction-budget-lint-test.sh +166 -0
- package/scripts/instruction-budget-lint.sh +219 -0
- package/scripts/integrations-check-test.sh +200 -0
- package/scripts/integrations-check.sh +157 -0
- package/scripts/kit-add-test.sh +214 -0
- package/scripts/kit-add.sh +305 -5
- package/scripts/kit-adopt-test.sh +16 -0
- package/scripts/kit-adopt.sh +3 -2
- package/scripts/kit-digest.sh +2 -2
- package/scripts/kit-doctor-test.sh +293 -0
- package/scripts/kit-doctor.sh +272 -140
- package/scripts/kit-export-project-test.sh +3 -3
- package/scripts/kit-remove-test.sh +19 -0
- package/scripts/kit-routines.sh +2 -2
- package/scripts/kit-self-update.sh +1 -1
- package/scripts/kit-version-check-test.sh +4 -0
- package/scripts/kit-version-check.sh +4 -2
- package/scripts/knowledge-lint.sh +4 -4
- package/scripts/leak-fence-test.sh +89 -0
- package/scripts/lib/adapter-select-test.sh +136 -0
- package/scripts/lib/adapter-select.sh +158 -0
- package/scripts/lib/agent-def-test.sh +69 -0
- package/scripts/lib/agent-def.sh +106 -0
- package/scripts/lib/agent-launch-test.sh +212 -0
- package/scripts/lib/agent-launch.sh +335 -0
- package/scripts/lib/board-view-test.sh +11 -0
- package/scripts/lib/board-view.sh +42 -26
- package/scripts/lib/branch-owner-test.sh +26 -0
- package/scripts/lib/branch-owner.sh +16 -9
- package/scripts/lib/captain-test.sh +105 -0
- package/scripts/lib/captain.sh +87 -8
- package/scripts/lib/codex-hooks-test.sh +100 -0
- package/scripts/lib/codex-hooks.sh +69 -0
- package/scripts/lib/commitlint.sh +1 -1
- package/scripts/lib/content-kinds-gc-test.sh +88 -0
- package/scripts/lib/copilot-test.sh +70 -4
- package/scripts/lib/copilot.sh +66 -14
- package/scripts/lib/effort-dispatch-test.sh +3 -3
- package/scripts/lib/effort-metrics-test.sh +178 -1
- package/scripts/lib/effort-metrics.sh +175 -35
- package/scripts/lib/effort-ops-test.sh +205 -7
- package/scripts/lib/effort-ops.sh +198 -43
- package/scripts/lib/effort-parity-test.sh +49 -13
- package/scripts/lib/effort-plan-test.sh +337 -0
- package/scripts/lib/effort-plan.sh +200 -23
- package/scripts/lib/effort.sh +56 -11
- package/scripts/lib/errors-header-test.sh +1 -1
- package/scripts/lib/gh-project-test.sh +35 -1
- package/scripts/lib/gh-project.sh +23 -16
- package/scripts/lib/gh-rest-test.sh +32 -3
- package/scripts/lib/gh-rest.sh +17 -2
- package/scripts/lib/hook-refresh.sh +1 -1
- package/scripts/lib/init-github.sh +412 -0
- package/scripts/lib/init-guide.sh +630 -0
- package/scripts/lib/integration-install-test.sh +343 -0
- package/scripts/lib/integration-install.sh +257 -0
- package/scripts/lib/integrations-test.sh +366 -0
- package/scripts/lib/integrations.sh +244 -0
- package/scripts/lib/kinds-test.sh +125 -0
- package/scripts/lib/kinds.sh +66 -0
- package/scripts/lib/kit-brief-test.sh +22 -3
- package/scripts/lib/kit-brief.sh +45 -5
- package/scripts/lib/kit-config-resolve.sh +2 -2
- package/scripts/lib/kit-config-test.sh +64 -1
- package/scripts/lib/kit-config.sh +37 -1
- package/scripts/lib/kit-events.sh +7 -0
- package/scripts/lib/kit-gc-test.sh +173 -1
- package/scripts/lib/kit-gc.sh +226 -37
- package/scripts/lib/kit-hotfix.sh +216 -0
- package/scripts/lib/kit-interview-test.sh +93 -0
- package/scripts/lib/kit-interview.sh +117 -8
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +3 -3
- package/scripts/lib/kit-local.sh +2 -2
- package/scripts/lib/kit-manifest.sh +33 -1
- package/scripts/lib/kit-profile-test.sh +3 -3
- package/scripts/lib/kit-status-test.sh +112 -4
- package/scripts/lib/kit-status.sh +246 -16
- package/scripts/lib/kit-task-ops-test.sh +37 -0
- package/scripts/lib/kit-task-ops.sh +175 -31
- package/scripts/lib/kto-hotfix-test.sh +232 -0
- package/scripts/lib/kto-task-close-test.sh +1 -1
- package/scripts/lib/kto-task-new-test.sh +95 -0
- package/scripts/lib/kto-task-pr-merge-test.sh +37 -3
- package/scripts/lib/kto-task-pr-test.sh +70 -0
- package/scripts/lib/leak-fence.sh +89 -0
- package/scripts/lib/light-task-run-test.sh +255 -0
- package/scripts/lib/light-task-test.sh +309 -0
- package/scripts/lib/light-task.sh +706 -0
- package/scripts/lib/next-test.sh +99 -0
- package/scripts/lib/next.sh +9 -3
- package/scripts/lib/orchestration-runtime-test.sh +72 -0
- package/scripts/lib/orchestration-runtime.sh +57 -5
- package/scripts/lib/plan-machine-test.sh +15 -2
- package/scripts/lib/plan-machine.sh +20 -7
- package/scripts/lib/plan-next-test.sh +1 -1
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +3 -3
- package/scripts/lib/pr-evidence.sh +1 -1
- package/scripts/lib/qa-lane-test.sh +626 -0
- package/scripts/lib/qa-lane.sh +1357 -0
- package/scripts/lib/qa-lanes-test.sh +175 -0
- package/scripts/lib/react-detect.sh +1 -1
- package/scripts/lib/render-test.sh +1 -1
- package/scripts/lib/review-page-test.sh +318 -0
- package/scripts/lib/review-page.sh +369 -0
- package/scripts/lib/review-stage-test.sh +62 -11
- package/scripts/lib/review-stage.sh +42 -60
- package/scripts/lib/role-identity-test.sh +65 -0
- package/scripts/lib/role-identity.sh +25 -2
- package/scripts/lib/secret-guard.sh +3 -3
- package/scripts/lib/session-registry-test.sh +111 -0
- package/scripts/lib/session-registry.sh +233 -0
- package/scripts/lib/stage-receipt-test.sh +14 -1
- package/scripts/lib/stage-receipt.sh +13 -8
- package/scripts/lib/task-source-file.sh +309 -0
- package/scripts/lib/task-source.sh +130 -0
- package/scripts/lib/upgrade-report-test.sh +120 -0
- package/scripts/lib/upgrade-report.sh +138 -0
- package/scripts/lib/version-bump.sh +3 -3
- package/scripts/lib/wave-result-test.sh +80 -0
- package/scripts/lib/wave-result.sh +127 -0
- package/scripts/lib/worker-brief-test.sh +5 -0
- package/scripts/lib/worker-brief.sh +2 -2
- package/scripts/lib/worktree-issue-test.sh +30 -1
- package/scripts/lib/worktree-issue.sh +82 -12
- package/scripts/lib/worktree-ports-test.sh +57 -4
- package/scripts/lib/worktree-start-test.sh +197 -0
- package/scripts/lib/worktree-start.sh +153 -31
- package/scripts/lib/zsh-safety-test.sh +19 -3
- package/scripts/marketing-walkthrough-test.sh +152 -0
- package/scripts/night-grant-test.sh +37 -0
- package/scripts/night-grant.sh +448 -0
- package/scripts/night-run-test.sh +8 -0
- package/scripts/night-run.mjs +275 -0
- package/scripts/night-run.test.mjs +324 -0
- package/scripts/orchestrate-test.sh +190 -0
- package/scripts/orchestrate.sh +79 -8
- package/scripts/portable-test.sh +11 -2
- package/scripts/publish.sh +28 -3
- package/scripts/review-lint-test.sh +7 -7
- package/scripts/review-lint.sh +2 -2
- package/scripts/review-rules.conf +8 -0
- package/scripts/rule-recipes-test.sh +96 -0
- package/scripts/self-install-test.sh +39 -9
- package/scripts/setup-labels.sh +18 -1
- package/scripts/setup-milestones.sh +1 -1
- package/scripts/showcase.sh +1 -1
- package/scripts/skill-frontmatter-lint-test.sh +4 -4
- package/scripts/skill-frontmatter-lint.sh +1 -1
- package/scripts/status-test.sh +113 -2
- package/scripts/status.sh +16 -3
- package/scripts/task-sync-test.sh +154 -0
- package/scripts/task-sync.sh +243 -32
- package/scripts/test-runner-test.sh +158 -0
- package/scripts/test.sh +131 -23
- package/scripts/update-path-test.sh +279 -0
- package/scripts/ux-ds-audit.sh +1 -1
- package/scripts/ux-graph-scan.sh +6 -6
- package/scripts/wave-worker.sh +54 -0
- package/skills/kit-add/SKILL.md +77 -0
- package/skills/kit-autopilot/SKILL.md +123 -12
- package/skills/kit-cleanup/SKILL.md +5 -2
- package/skills/kit-contribute/SKILL.md +4 -4
- package/skills/kit-docs-writer/SKILL.md +16 -6
- package/skills/kit-effort-close/SKILL.md +17 -8
- package/skills/kit-effort-new/SKILL.md +15 -9
- package/skills/kit-effort-pr/SKILL.md +15 -7
- package/skills/kit-effort-start/SKILL.md +5 -2
- package/skills/kit-gc/SKILL.md +5 -2
- package/skills/kit-next/SKILL.md +5 -1
- package/skills/kit-onboard/SKILL.md +3 -3
- package/skills/kit-page/SKILL.md +93 -0
- package/skills/kit-plan-next/SKILL.md +8 -4
- package/skills/kit-security-sweep/SKILL.md +1 -3
- package/skills/kit-ship/SKILL.md +2 -3
- package/skills/kit-status/SKILL.md +35 -4
- package/skills/kit-task-new/SKILL.md +3 -3
- package/skills/kit-task-pr/SKILL.md +7 -2
- package/skills/kit-task-pr-merge/SKILL.md +7 -2
- package/skills/kit-task-start/SKILL.md +7 -7
- package/skills/kit-task-sync/SKILL.md +19 -3
- package/skills/kit-ux-audit/SKILL.md +3 -2
- package/templates/agents/auto-dev.md +5 -4
- package/templates/agents/backend.md +1 -1
- package/templates/agents/designer.md +2 -0
- package/templates/agents/devops.md +1 -1
- package/templates/agents/editor.md +9 -1
- package/templates/agents/frontend.md +1 -1
- package/templates/agents/local-delegate.md +1 -1
- package/templates/agents/pm.md +5 -5
- package/templates/agents/tech-lead.md +1 -1
- package/templates/benchmarks/SCHEMA.md +9 -3
- package/templates/codex/hooks.json.tmpl +89 -0
- package/templates/hooks/guard-base-branch-commit.sh.tmpl +13 -7
- package/templates/hooks/guard-raw-git-ops.sh.tmpl +12 -12
- package/templates/hooks/mempal_followup.sh.tmpl +2 -2
- package/templates/hooks/mempal_session_start.sh.tmpl +1 -1
- package/templates/hooks/prepush_gate.sh.tmpl +4 -2
- package/templates/hooks/repo-hygiene.sh.tmpl +3 -2
- package/templates/instructions.md.tmpl +174 -0
- package/templates/kit.config.json.tmpl +3 -3
- package/templates/knowledge-INDEX.md.tmpl +1 -1
- package/templates/lib/kit-sigil.sh.tmpl +1 -1
- package/templates/rules/authoring.md +106 -0
- package/templates/rules/branch-naming.md +40 -4
- package/templates/rules/code-retrieval.md +63 -0
- package/templates/rules/delegation-brief.md +0 -3
- package/templates/rules/design-routing.md +3 -3
- package/templates/rules/effort-model.md +14 -10
- package/templates/rules/gate-and-review.md +94 -0
- package/templates/rules/issue-lifecycle.md +88 -0
- package/templates/rules/knowledge-base.md +1 -1
- package/templates/rules/mempalace.md +1 -1
- package/templates/rules/merge-safety.md +108 -0
- package/templates/rules/naming-and-ids.md +23 -17
- package/templates/rules/plain-language.md +59 -0
- package/templates/rules/plan-next.md +9 -11
- package/templates/rules/react-annotate.md +6 -0
- package/templates/rules/review-pages.md +49 -0
- package/templates/rules/risk-tiered-review.md +13 -4
- package/templates/rules/shared-checkout.md +106 -0
- package/templates/rules/skill-gaps.md +2 -7
- package/templates/rules/task-management.md +13 -1
- package/templates/skills/brand-voice/SKILL.md +91 -0
- package/templates/skills/brand-voice/references/voice-template.md +61 -0
- package/templates/skills/campaign/SKILL.md +123 -0
- package/templates/skills/campaign/references/plan-template.md +55 -0
- package/templates/skills/concrete/SKILL.md +2 -2
- package/templates/skills/copywriting/SKILL.md +8 -1
- package/templates/skills/feature-build-refine/SKILL.md +2 -4
- package/templates/skills/morning-briefing/SKILL.md +2 -2
- package/templates/skills/page-design/SKILL.md +145 -0
- package/templates/skills/page-design/add.json +5 -0
- package/templates/skills/page-design/references/design-file-template.md +40 -0
- package/templates/skills/page-design/references/generic-page-patterns.md +43 -0
- package/templates/skills/page-design/references/minimum-rules.md +42 -0
- package/templates/skills/speckit/SKILL.md +4 -5
- package/templates/skills/supabase-patterns/SKILL.md +1 -1
- package/commands/kit-add.md +0 -42
- package/templates/CLAUDE.md.tmpl +0 -106
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# kto-task-new-test.sh — kto_task_new against a stubbed gh (#387): a label the repo does not have
|
|
3
|
+
# is dropped with a warning and the issue is still created; with every label present the create
|
|
4
|
+
# call is unchanged; a failed create returns non-zero and prints no URL.
|
|
5
|
+
# Run: bash scripts/lib/kto-task-new-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
|
+
set -u
|
|
8
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
9
|
+
fail=0
|
|
10
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
11
|
+
tc() { if grep -qE -- "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
12
|
+
tn() { if grep -qE -- "$2" "$1"; then echo "FAIL: $3 (/$2/ in $1)"; fail=1; else echo "ok: $3"; fi; }
|
|
13
|
+
|
|
14
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
15
|
+
export GH_LOG="$tmp/gh.log"; : > "$GH_LOG"
|
|
16
|
+
mkdir -p "$tmp/bin"
|
|
17
|
+
# GH_HAVE: the repo's labels, comma-separated. GH_LIST_FAIL=1: `gh label list` fails.
|
|
18
|
+
# GH_CREATE_FAIL=1: `gh issue create` fails. Like real gh, a create naming a label the repo does
|
|
19
|
+
# not have fails with "could not add label".
|
|
20
|
+
cat > "$tmp/bin/gh" <<'SH'
|
|
21
|
+
#!/usr/bin/env bash
|
|
22
|
+
echo "$*" >> "$GH_LOG"
|
|
23
|
+
case "$1 $2" in
|
|
24
|
+
"label list")
|
|
25
|
+
[ -n "${GH_LIST_FAIL:-}" ] && { echo "gh: HTTP 403" >&2; exit 1; }
|
|
26
|
+
printf '%s\n' "$GH_HAVE" | tr ',' '\n' ;;
|
|
27
|
+
"issue create")
|
|
28
|
+
[ -n "${GH_CREATE_FAIL:-}" ] && { echo "gh: HTTP 500" >&2; exit 1; }
|
|
29
|
+
want=""; while [ $# -gt 0 ]; do [ "$1" = "--label" ] && want="${2:-}"; shift; done
|
|
30
|
+
for l in $(printf '%s' "$want" | tr ',' ' '); do
|
|
31
|
+
case ",$(printf '%s' "$GH_HAVE" | tr 'A-Z' 'a-z')," in *",$l,"*) ;; *) echo "could not add label: '$l' not found" >&2; exit 1 ;; esac
|
|
32
|
+
done
|
|
33
|
+
echo "https://github.com/o/r/issues/50" ;;
|
|
34
|
+
*) exit 0 ;;
|
|
35
|
+
esac
|
|
36
|
+
SH
|
|
37
|
+
chmod +x "$tmp/bin/gh"
|
|
38
|
+
export PATH="$tmp/bin:$PATH" KIT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_PROJECTS_V2="false"
|
|
39
|
+
unset KIT_CONFIG CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT GH_LIST_FAIL GH_CREATE_FAIL
|
|
40
|
+
cd "$tmp" || exit 1
|
|
41
|
+
|
|
42
|
+
# shellcheck source=/dev/null
|
|
43
|
+
. "$LIB/kit-task-ops.sh"
|
|
44
|
+
|
|
45
|
+
# ── a missing label is a warning, not an abort ────────────────────────────────────────────────────
|
|
46
|
+
export GH_HAVE="kind:task,priority:p2,role:backend"
|
|
47
|
+
: > "$GH_LOG"
|
|
48
|
+
kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
49
|
+
t "missing kind label: rc 0" "$rc" "0"
|
|
50
|
+
tc "$tmp/out" '^✓ https://github.com/o/r/issues/50$' "missing kind label: prints the issue URL"
|
|
51
|
+
t "missing kind label: echoes the number" "$(tail -1 "$tmp/out")" "50"
|
|
52
|
+
tc "$tmp/err" "kind:feat" "missing kind label: the warning names kind:feat"
|
|
53
|
+
tc "$GH_LOG" '^issue create .*--label priority:p2,role:backend( |$)' "missing kind label: only existing labels are sent"
|
|
54
|
+
tn "$GH_LOG" '^issue create .*kind:feat' "missing kind label: kind:feat is not sent"
|
|
55
|
+
tn "$GH_LOG" '^label create' "missing kind label: no label is created"
|
|
56
|
+
|
|
57
|
+
# Label names are case-insensitive on GitHub.
|
|
58
|
+
export GH_HAVE="Kind:Feat,priority:p2,role:backend"
|
|
59
|
+
: > "$GH_LOG"
|
|
60
|
+
kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
61
|
+
t "case-insensitive match: rc 0" "$rc" "0"
|
|
62
|
+
t "case-insensitive match: no warning" "$(grep -c 'kind:feat' "$tmp/err")" "0"
|
|
63
|
+
tc "$GH_LOG" '^issue create .*--label kind:feat,priority:p2,role:backend ' "case-insensitive match: the label is sent"
|
|
64
|
+
|
|
65
|
+
# ── every label missing: the issue is created with no --label at all ──────────────────────────────
|
|
66
|
+
export GH_HAVE="bug"
|
|
67
|
+
: > "$GH_LOG"
|
|
68
|
+
kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
69
|
+
t "no label exists: rc 0" "$rc" "0"
|
|
70
|
+
tc "$tmp/out" '^✓ https://github.com/o/r/issues/50$' "no label exists: prints the issue URL"
|
|
71
|
+
tn "$GH_LOG" '^issue create .*--label' "no label exists: no --label flag"
|
|
72
|
+
t "no label exists: three labels warned" "$(grep -cE 'kind:feat|priority:p2|role:backend' "$tmp/err")" "3"
|
|
73
|
+
|
|
74
|
+
# ── all labels present: the create call is unchanged ──────────────────────────────────────────────
|
|
75
|
+
export GH_HAVE="kind:feat,priority:p2,role:backend"
|
|
76
|
+
: > "$GH_LOG"
|
|
77
|
+
kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
78
|
+
t "all labels present: rc 0" "$rc" "0"
|
|
79
|
+
tc "$GH_LOG" '^issue create --repo o/r --title Test --body .*--label kind:feat,priority:p2,role:backend --assignee @me$' "all labels present: the create call is unchanged"
|
|
80
|
+
t "all labels present: no warning" "$(wc -c < "$tmp/err" | tr -d ' ')" "0"
|
|
81
|
+
|
|
82
|
+
# ── the label list cannot be read: send every label, as before ────────────────────────────────────
|
|
83
|
+
: > "$GH_LOG"
|
|
84
|
+
GH_LIST_FAIL=1 kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
85
|
+
t "unreadable label list: rc 0" "$rc" "0"
|
|
86
|
+
tc "$GH_LOG" '^issue create .*--label kind:feat,priority:p2,role:backend ' "unreadable label list: every label is sent"
|
|
87
|
+
|
|
88
|
+
# ── the create itself fails: non-zero, no URL ─────────────────────────────────────────────────────
|
|
89
|
+
: > "$GH_LOG"
|
|
90
|
+
GH_CREATE_FAIL=1 kto_task_new "Test" backend feat p2 "" "" "" x >"$tmp/out" 2>"$tmp/err"; rc=$?
|
|
91
|
+
t "create fails: rc non-zero" "$([ "$rc" -ne 0 ] && echo nonzero)" "nonzero"
|
|
92
|
+
t "create fails: prints nothing on stdout" "$(wc -c < "$tmp/out" | tr -d ' ')" "0"
|
|
93
|
+
|
|
94
|
+
[ "$fail" -eq 0 ] && echo "kto-task-new: all passed" || echo "kto-task-new: FAILURES"
|
|
95
|
+
exit "$fail"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# kto-task-pr-merge-test.sh — kto_task_pr_merge never acts on the base branch (#366), cleans up from
|
|
3
3
|
# the PR's own worktree (#371), and merges by squash, merge commit or rebase into develop or an
|
|
4
|
-
# effort branch (#376).
|
|
4
|
+
# effort branch (#376). An effort/* HEAD is refused — its PR merges with `cckit effort close` (#379).
|
|
5
5
|
# A flag taken as the PR number used to "merge" (gh pr merge --help exits 0) and then run the branch
|
|
6
6
|
# cleanup on the base branch; a conflicting PR merged from the hub would rebase + force-push it.
|
|
7
7
|
# Hermetic: stubbed gh, throwaway repo + bare remote. Run: bash scripts/lib/kto-task-pr-merge-test.sh
|
|
@@ -14,14 +14,19 @@ t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]'
|
|
|
14
14
|
command -v jq >/dev/null 2>&1 || { echo "kto-task-pr-merge-test: jq required" >&2; exit 1; }
|
|
15
15
|
|
|
16
16
|
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
17
|
-
export GH_LOG="$tmp/gh.log" GH_MERGEABLE="MERGEABLE" GH_BASE="develop" GH_HEAD=""; : > "$GH_LOG"
|
|
17
|
+
export GH_LOG="$tmp/gh.log" GH_MERGEABLE="MERGEABLE" GH_BASE="develop" GH_HEAD="" GH_CLOSING="" GH_ISSUE_STATE=""; : > "$GH_LOG"
|
|
18
18
|
mkdir -p "$tmp/bin"
|
|
19
19
|
cat > "$tmp/bin/gh" <<'SH'
|
|
20
20
|
#!/usr/bin/env bash
|
|
21
21
|
echo "$*" >> "$GH_LOG"
|
|
22
22
|
case "$1 $2" in
|
|
23
|
-
"pr view")
|
|
23
|
+
"pr view") case "$*" in
|
|
24
|
+
*closingIssuesReferences*) [ -n "${GH_CLOSING:-}" ] && printf '%s\n' $GH_CLOSING; exit 0 ;;
|
|
25
|
+
*"--json body"*) exit 0 ;;
|
|
26
|
+
esac
|
|
27
|
+
printf '{"mergeable":"%s","mergeStateStatus":"CLEAN","baseRefName":"%s","headRefName":"%s"}\n' \
|
|
24
28
|
"$GH_MERGEABLE" "${GH_BASE:-develop}" "${GH_HEAD:-}" ;;
|
|
29
|
+
"issue view") [ -n "${GH_ISSUE_STATE:-}" ] && echo "$GH_ISSUE_STATE"; exit 0 ;;
|
|
25
30
|
*) exit 0 ;;
|
|
26
31
|
esac
|
|
27
32
|
SH
|
|
@@ -125,5 +130,34 @@ t "the sub branch (not the cwd branch) is deleted" "$(git branch --list sub/5b-y
|
|
|
125
130
|
t "and on origin" "$(git ls-remote --heads origin sub/5b-y | wc -l | tr -d ' ')" "0"
|
|
126
131
|
t "effort/5-e is still on origin" "$(git ls-remote --heads origin effort/5-e | wc -l | tr -d ' ')" "1"
|
|
127
132
|
|
|
133
|
+
# ── #379: the linked-issue loop does not depend on IFS ───────────────────────────────────────────
|
|
134
|
+
# The effort worktree lives under the main checkout here; keep it out of `git status` so the main
|
|
135
|
+
# checkout reads clean.
|
|
136
|
+
echo ".claude/" >> "$tmp/work/.git/info/exclude"
|
|
137
|
+
# A caller that left IFS NUL-polluted made `for n in $issues` pass "21\n22" as ONE issue number.
|
|
138
|
+
: > "$GH_LOG"; GH_BASE="develop"; GH_HEAD="fix/20-x"; GH_CLOSING="21 22"; GH_ISSUE_STATE="OPEN"
|
|
139
|
+
( IFS=$'\0'; kto_task_pr_merge 20 ) >/dev/null 2>&1; rc=$?
|
|
140
|
+
t "merge under IFS=\$'\\0' exits 0" "$rc" "0"
|
|
141
|
+
t "issue 21 is closed on its own" "$(grep -c '^issue close 21 ' "$GH_LOG")" "1"
|
|
142
|
+
t "issue 22 is closed on its own" "$(grep -c '^issue close 22 ' "$GH_LOG")" "1"
|
|
143
|
+
t "exactly two issue close calls" "$(grep -c '^issue close ' "$GH_LOG")" "2"
|
|
144
|
+
GH_CLOSING=""; GH_ISSUE_STATE=""
|
|
145
|
+
|
|
146
|
+
# ── #379: an effort/* head is refused — the squash would destroy the per-sub trace ───────────────
|
|
147
|
+
: > "$GH_LOG"; GH_BASE="develop"; GH_HEAD="effort/5-e"
|
|
148
|
+
kto_task_pr_merge 14 >/dev/null 2>"$tmp/err14"; rc=$?
|
|
149
|
+
t "an effort head is refused (rc 1)" "$rc" "1"
|
|
150
|
+
t "the refusal names cckit effort close 5" "$(grep -c 'cckit effort close 5' "$tmp/err14")" "1"
|
|
151
|
+
t "nothing was merged on the effort refusal" "$(grep -c 'pr merge' "$GH_LOG")" "0"
|
|
152
|
+
t "the refused effort branch survives" "$(git branch --list effort/5-e | tr -d ' *+')" "effort/5-e"
|
|
153
|
+
( cd "$ewt" && kto_task_pr_merge ) >/dev/null 2>&1; rc=$?
|
|
154
|
+
t "refused from the effort worktree too (rc 1)" "$rc" "1"
|
|
155
|
+
t "still nothing merged" "$(grep -c 'pr merge' "$GH_LOG")" "0"
|
|
156
|
+
: > "$GH_LOG"
|
|
157
|
+
KIT_FORCE=1 kto_task_pr_merge 14 >/dev/null 2>"$tmp/err14f"; rc=$?
|
|
158
|
+
t "KIT_FORCE=1 merges the effort head (rc 0)" "$rc" "0"
|
|
159
|
+
t "KIT_FORCE=1 warns about the lost trace" "$(grep -c 'KIT_FORCE=1' "$tmp/err14f")" "1"
|
|
160
|
+
t "KIT_FORCE=1 reaches gh pr merge" "$(grep -c 'pr merge 14' "$GH_LOG")" "1"
|
|
161
|
+
|
|
128
162
|
[ "$fail" -eq 0 ] && echo "kto-task-pr-merge: all passed" || echo "kto-task-pr-merge: FAILURES"
|
|
129
163
|
exit "$fail"
|
|
@@ -55,5 +55,75 @@ KIT_PR_TITLE_STYLE=conventional kto_task_pr 43 "Other." >/dev/null 2>&1
|
|
|
55
55
|
tc "$GH_LOG" 'pr create .*--title fix: Fix the thing' "conventional (default): a Conventional Commits title"
|
|
56
56
|
grep -q 'For the orchestrator' "$GH_LOG" && { echo "FAIL: section present with the switch off"; fail=1; } || echo "ok: no section with the switch off"
|
|
57
57
|
|
|
58
|
+
# --base (#391): an explicit base wins over the configured one; the flag is never a positional.
|
|
59
|
+
: > "$GH_LOG"; git checkout -q -b task/44-release
|
|
60
|
+
echo three > tracked.txt
|
|
61
|
+
kto_task_pr 44 "Release." --base release >/dev/null 2>&1
|
|
62
|
+
t "--base: rc 0" "$?" "0"
|
|
63
|
+
tc "$GH_LOG" 'pr create .*--base release --head task/44-release' "--base: the PR targets the given base"
|
|
64
|
+
t "--base is not taken as the commit message" "$(git log -1 --format=%s)" "fix: Fix the thing"
|
|
65
|
+
: > "$GH_LOG"
|
|
66
|
+
kto_task_pr 44 "Release." >/dev/null 2>&1
|
|
67
|
+
tc "$GH_LOG" 'pr create .*--base main --head task/44-release' "no --base: the PR targets the configured base"
|
|
68
|
+
: > "$GH_LOG"
|
|
69
|
+
kto_task_pr --base=release 44 "Release." >/dev/null 2>&1
|
|
70
|
+
tc "$GH_LOG" 'pr create .*--base release --head task/44-release' "--base=<branch> before the positionals"
|
|
71
|
+
: > "$GH_LOG"
|
|
72
|
+
kto_task_pr 44 "Release." "custom subject" --base release >/dev/null 2>&1
|
|
73
|
+
tc "$GH_LOG" 'pr create .*--base release ' "--base after an explicit commit message"
|
|
74
|
+
|
|
75
|
+
: > "$GH_LOG"; git checkout -q -b task/45-no-value
|
|
76
|
+
echo four > tracked.txt
|
|
77
|
+
kto_task_pr 45 "No value." --base >/dev/null 2>"$tmp/err"
|
|
78
|
+
t "--base with no value: rc 2" "$?" "2"
|
|
79
|
+
tc "$tmp/err" '[-]-base needs a branch' "--base with no value: says what is missing"
|
|
80
|
+
t "--base with no value: no gh call" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
81
|
+
t "--base with no value: nothing pushed" "$(git ls-remote --heads origin task/45-no-value | wc -l | tr -d ' ')" "0"
|
|
82
|
+
t "--base with no value: nothing committed" "$(git status --porcelain --untracked-files=no | wc -l | tr -d ' ')" "1"
|
|
83
|
+
kto_task_pr 45 "No value." --base= >/dev/null 2>&1
|
|
84
|
+
t "--base= (empty): rc 2" "$?" "2"
|
|
85
|
+
|
|
86
|
+
# the dispatcher: `cckit pr --help` prints the usage and reaches neither gh nor the remote.
|
|
87
|
+
: > "$GH_LOG"
|
|
88
|
+
out="$("$LIB/../../bin/cckit" pr --help 2>/dev/null)"
|
|
89
|
+
t "cckit pr --help: rc 0" "$?" "0"
|
|
90
|
+
case "$out" in *'[--base <branch>]'*) echo "ok: cckit pr --help shows --base" ;; *) echo "FAIL: cckit pr --help -> '$out'"; fail=1 ;; esac
|
|
91
|
+
t "cckit pr --help: no gh call" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
92
|
+
grep -qE '^# cckit pr <issue> <summary> \[--base <branch>\]' "$LIB/../../bin/cckit" \
|
|
93
|
+
&& echo "ok: the usage header shows --base" || { echo "FAIL: usage header lacks --base"; fail=1; }
|
|
94
|
+
|
|
95
|
+
# --base (#360): the flag wins over the configured integration branch, and the PR's target reaches a
|
|
96
|
+
# git pre-push hook as KIT_PR_BASE.
|
|
97
|
+
cat > .git/hooks/pre-push <<SH
|
|
98
|
+
#!/usr/bin/env bash
|
|
99
|
+
echo "KIT_PR_BASE=\${KIT_PR_BASE:-}" >> "$tmp/prepush.log"
|
|
100
|
+
SH
|
|
101
|
+
chmod +x .git/hooks/pre-push
|
|
102
|
+
export KIT_BASE_BRANCH="develop" # what load_kit_config exported from the config
|
|
103
|
+
: > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/44-hot
|
|
104
|
+
echo three > tracked.txt
|
|
105
|
+
kto_task_pr 44 "Hot." --base main >/dev/null 2>&1
|
|
106
|
+
t "--base: kto_task_pr succeeds" "$?" "0"
|
|
107
|
+
tc "$GH_LOG" 'pr create .*--base main( |$)' "--base main: the PR targets main, not the configured develop"
|
|
108
|
+
t "--base main: the pre-push hook sees it" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=main"
|
|
109
|
+
t "--base is not taken as the commit msg" "$(git log -1 --format=%s)" "fix: Fix the thing"
|
|
110
|
+
|
|
111
|
+
: > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/45-eq
|
|
112
|
+
echo four > tracked.txt
|
|
113
|
+
kto_task_pr --base=main 45 "Eq." "fix: custom msg" >/dev/null 2>&1
|
|
114
|
+
tc "$GH_LOG" 'pr create .*--base main( |$)' "--base=main before the positionals works too"
|
|
115
|
+
t "the commit message positional survives" "$(git log -1 --format=%s)" "fix: custom msg"
|
|
116
|
+
|
|
117
|
+
: > "$GH_LOG"; : > "$tmp/prepush.log"; git checkout -q -b fix/46-default
|
|
118
|
+
echo five > tracked.txt
|
|
119
|
+
kto_task_pr 46 "Default." >/dev/null 2>&1
|
|
120
|
+
tc "$GH_LOG" 'pr create .*--base develop( |$)' "no --base: the configured integration branch"
|
|
121
|
+
t "no --base: the hook gets the integration branch" "$(cat "$tmp/prepush.log")" "KIT_PR_BASE=develop"
|
|
122
|
+
|
|
123
|
+
: > "$GH_LOG"; git checkout -q -b fix/47-bad
|
|
124
|
+
kto_task_pr 47 "Bad." --base >/dev/null 2>"$tmp/err"
|
|
125
|
+
t "--base with no value is refused" "$?" "2"
|
|
126
|
+
t "…before any gh call" "$(wc -l < "$GH_LOG" | tr -d ' ')" "0"
|
|
127
|
+
|
|
58
128
|
[ "$fail" -eq 0 ] && echo "kto-task-pr: all passed" || echo "kto-task-pr: FAILURES"
|
|
59
129
|
exit "$fail"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# leak-fence.sh — the leak fence: no private word ships in a tracked file.
|
|
4
|
+
#
|
|
5
|
+
# cckit is public and is developed next to private repositories. This fence is what keeps a product
|
|
6
|
+
# name, a client name, a person's name or a private path from landing in a commit. It is one scan
|
|
7
|
+
# with three pattern sources, so there is exactly one place to generalize:
|
|
8
|
+
#
|
|
9
|
+
# 1. the built-in pattern — the legacy brand name this kit was extracted from (`tedos`). It is
|
|
10
|
+
# always on, so a fresh clone or a fork with no local list still fails on it.
|
|
11
|
+
# 2. `.cckit/leak-words` — one extended regex per line, `#` comments and blank lines skipped,
|
|
12
|
+
# matched case-insensitively. The file is gitignored (`.cckit/` as a whole) and MUST stay so:
|
|
13
|
+
# a committed denylist publishes the very words it hides. Resolved through the shared `.cckit/`
|
|
14
|
+
# when kit-state.sh is loaded, so every worktree reads the same list.
|
|
15
|
+
# 3. `CCKIT_LEAK_WORDS` — the same patterns for CI, separated by newlines or `|`. Set it from a
|
|
16
|
+
# repository secret; the workflow passes it as an env var to the gate step.
|
|
17
|
+
#
|
|
18
|
+
# A hit is reported as `file:line` only. The matched text is never printed: in CI the log is
|
|
19
|
+
# public, and echoing the line would leak the word the fence exists to hide.
|
|
20
|
+
#
|
|
21
|
+
# Scope: tracked files (`git grep`), so gitignored runtime state (.cckit/), build output and deps
|
|
22
|
+
# never trip it. This file is excluded from its own scan (it names the built-in pattern). Outside a
|
|
23
|
+
# git work tree a filtered recursive grep stands in.
|
|
24
|
+
#
|
|
25
|
+
# Pattern note: `\b` is a GNU extension. git grep -E on macOS compiles patterns with the system
|
|
26
|
+
# regcomp, where `\b` matches nothing, so a pattern written with it passes locally and fails in CI.
|
|
27
|
+
# Write `([^[:alnum:]]|$)` for a word end instead.
|
|
28
|
+
#
|
|
29
|
+
# API:
|
|
30
|
+
# leak_fence_patterns print the active patterns, one per line (built-in first)
|
|
31
|
+
# leak_fence_scan print `file:line` for every hit; exit 0 when there are hits
|
|
32
|
+
# leak_fence_check the gate step: 0 clean, 1 hits (file:line list on stderr)
|
|
33
|
+
# errors: strict — a missing list file is not an error (built-in word only); a hit returns 1 and names
|
|
34
|
+
# file:line, never the matched text
|
|
35
|
+
|
|
36
|
+
LEAK_FENCE_BUILTIN='tedos'
|
|
37
|
+
LEAK_FENCE_SELF='scripts/lib/leak-fence.sh'
|
|
38
|
+
|
|
39
|
+
leak_fence_list_file() {
|
|
40
|
+
if [ -n "${CCKIT_LEAK_WORDS_FILE:-}" ]; then printf '%s\n' "$CCKIT_LEAK_WORDS_FILE"
|
|
41
|
+
elif command -v kit_state_file >/dev/null 2>&1; then kit_state_file leak-words
|
|
42
|
+
else printf '%s\n' ".cckit/leak-words"; fi
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
leak_fence_patterns() {
|
|
46
|
+
local list
|
|
47
|
+
printf '%s\n' "$LEAK_FENCE_BUILTIN"
|
|
48
|
+
list="$(leak_fence_list_file)"
|
|
49
|
+
if [ -f "$list" ]; then
|
|
50
|
+
sed -e 's/^[[:space:]]*#.*//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "$list" | grep -v '^$' || true
|
|
51
|
+
fi
|
|
52
|
+
if [ -n "${CCKIT_LEAK_WORDS:-}" ]; then
|
|
53
|
+
# Comment lines are dropped BEFORE the `|` split: a secret set from the list file carries them,
|
|
54
|
+
# and a comment that contains `|` would otherwise split into an unbalanced, invalid pattern.
|
|
55
|
+
printf '%s\n' "$CCKIT_LEAK_WORDS" | sed -e 's/^[[:space:]]*#.*//' | tr '|' '\n' \
|
|
56
|
+
| sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | grep -v '^$' || true
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Exit: 0 hits printed, 1 no hits, 2 the pattern set did not compile (grep's own rc) — a scan that
|
|
61
|
+
# cannot run is not a clean scan, so leak_fence_check fails on 2 instead of passing on empty output.
|
|
62
|
+
leak_fence_scan() {
|
|
63
|
+
local pat rc
|
|
64
|
+
pat="$(leak_fence_patterns | paste -sd'|' -)"
|
|
65
|
+
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
66
|
+
git grep -inIE "$pat" -- . ":!$LEAK_FENCE_SELF" | cut -d: -f1,2
|
|
67
|
+
rc=${PIPESTATUS[0]}
|
|
68
|
+
else
|
|
69
|
+
grep -rniIE --exclude-dir=.git --exclude-dir=node_modules --exclude-dir=.cckit \
|
|
70
|
+
--exclude-dir=dist --exclude=leak-fence.sh "$pat" . | cut -d: -f1,2
|
|
71
|
+
rc=${PIPESTATUS[0]}
|
|
72
|
+
fi
|
|
73
|
+
[ "$rc" -le 1 ] || return 2
|
|
74
|
+
return "$rc"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
leak_fence_check() {
|
|
78
|
+
local hits n rc
|
|
79
|
+
hits="$(leak_fence_scan 2>/dev/null)"; rc=$?
|
|
80
|
+
if [ "$rc" -ge 2 ]; then
|
|
81
|
+
printf 'x leak fence: the pattern set did not compile (a list or CCKIT_LEAK_WORDS entry is not a valid extended regex); the scan did not run\n' >&2
|
|
82
|
+
return 1
|
|
83
|
+
fi
|
|
84
|
+
[ -z "$hits" ] && return 0
|
|
85
|
+
n="$(printf '%s\n' "$hits" | grep -c .)"
|
|
86
|
+
printf 'x leak fence: %s tracked line(s) contain a private word (file:line; the text is not shown):\n' "$n" >&2
|
|
87
|
+
printf '%s\n' "$hits" | sed -n 1,40p >&2
|
|
88
|
+
return 1
|
|
89
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# light-task-run-test.sh — `cckit task run <id>` end to end (#496): start, ONE headless objective
|
|
4
|
+
# built from the task record, finish, the review link.
|
|
5
|
+
#
|
|
6
|
+
# Hermetic, in the style of scripts/autopilot-run-test.sh: `claude` and `codex` are one stub script
|
|
7
|
+
# on PATH whose behaviour STUB_MODE selects, `gh` is a stub that logs every call, origin is a bare
|
|
8
|
+
# repository in the temp dir. It proves what cckit decides around the agent process (which steps
|
|
9
|
+
# run, what opens a review, the exit code); it does not prove a real agent does the task.
|
|
10
|
+
#
|
|
11
|
+
# Covers: a run from a draft opens one review; a re-run after the review is open reports it and
|
|
12
|
+
# starts no agent; a failing gate opens none and exits 6; a stopped earlier run is discarded and a
|
|
13
|
+
# round that changed nothing opens none (exit 5); the gate precedence --check > tasks.check > none;
|
|
14
|
+
# --no-finish stops before the review; --llm is one JSON object; usage errors.
|
|
15
|
+
# Page tasks (#504): the rule (kind `page`, or tasks.design in the config); the objective names the
|
|
16
|
+
# page-design skill; the review lists exactly the skills the stub's event output shows as loaded,
|
|
17
|
+
# says so when none was, and says "not known" when the output held no event.
|
|
18
|
+
# Run: bash scripts/lib/light-task-run-test.sh
|
|
19
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
20
|
+
set -u
|
|
21
|
+
LIB="$(cd "$(dirname "$0")" && pwd)"
|
|
22
|
+
CCKIT="$(cd "$LIB/../.." && pwd)/bin/cckit"
|
|
23
|
+
# shellcheck source=/dev/null
|
|
24
|
+
. "$LIB/test-env.sh" && test_env_seal
|
|
25
|
+
unset CLAUDE_CODE_REMOTE CCKIT_GH_TRANSPORT
|
|
26
|
+
fail=0
|
|
27
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
28
|
+
has() { case "$2" in *"$3"*) echo "ok: $1" ;; *) echo "FAIL: $1 -> '[$2]' lacks '[$3]'"; fail=1 ;; esac; }
|
|
29
|
+
hasnt() { case "$2" in *"$3"*) echo "FAIL: $1 -> '[$2]' has '[$3]'"; fail=1 ;; *) echo "ok: $1" ;; esac; }
|
|
30
|
+
command -v jq >/dev/null 2>&1 || { echo "light-task-run-test: jq absent — skipping"; exit 0; }
|
|
31
|
+
|
|
32
|
+
tmp="$(cd "$(mktemp -d)" && pwd -P)"; trap 'rm -rf "$tmp"' EXIT
|
|
33
|
+
export FX="$tmp" GH_LOG="$tmp/gh.log" GH_OPEN_URL=""
|
|
34
|
+
: > "$GH_LOG"
|
|
35
|
+
mkdir -p "$tmp/bin"
|
|
36
|
+
|
|
37
|
+
# The agent stub: reads the prompt on stdin like the real CLIs, then does what STUB_MODE says in
|
|
38
|
+
# the directory it was started in (the task's worktree).
|
|
39
|
+
cat > "$tmp/bin/agent-stub" <<'STUB'
|
|
40
|
+
#!/usr/bin/env bash
|
|
41
|
+
me="$(basename "$0")"
|
|
42
|
+
printf '%s\n' "$*" > "$FX/$me.argv"
|
|
43
|
+
cat > "$FX/$me.prompt"
|
|
44
|
+
pwd > "$FX/$me.cwd"
|
|
45
|
+
n="$(cat "$FX/rounds" 2>/dev/null || echo 0)"; n=$((n + 1)); echo "$n" > "$FX/rounds"
|
|
46
|
+
case "${STUB_MODE:-work}" in
|
|
47
|
+
work) echo "round $n" >> page.txt; git add -A >/dev/null 2>&1; git commit -q -m "round $n"
|
|
48
|
+
echo "made in round $n" > made.txt ;; # left uncommitted: `finish --all` has to carry it
|
|
49
|
+
idle) : ;;
|
|
50
|
+
esac
|
|
51
|
+
# Event output, only when cckit asked for it (`--output-format stream-json`): one Skill call per
|
|
52
|
+
# name in STUB_SKILLS. A name ending in `!` is a call the runtime answered with an error — a skill
|
|
53
|
+
# that is not installed. STUB_EVENTS=0 prints no event at all.
|
|
54
|
+
case "$*" in *stream-json*)
|
|
55
|
+
if [ "${STUB_EVENTS:-1}" = 1 ]; then
|
|
56
|
+
printf '{"type":"system","subtype":"init","skills":["page-design","impeccable","emil-design-eng","web-design-guidelines","concrete"]}\n'
|
|
57
|
+
i=0
|
|
58
|
+
for sk in ${STUB_SKILLS:-}; do
|
|
59
|
+
i=$((i + 1)); err=false
|
|
60
|
+
case "$sk" in *!) sk="${sk%!}"; err=true ;; esac
|
|
61
|
+
printf '{"type":"assistant","message":{"role":"assistant","content":[{"type":"tool_use","id":"t%s","name":"Skill","input":{"skill":"%s"}}]}}\n' "$i" "$sk"
|
|
62
|
+
printf '{"type":"user","message":{"role":"user","content":[{"type":"tool_result","tool_use_id":"t%s","is_error":%s,"content":"x"}]}}\n' "$i" "$err"
|
|
63
|
+
done
|
|
64
|
+
printf '{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"I used impeccable, emil-design-eng and web-design-guidelines."}]}}\n'
|
|
65
|
+
fi ;;
|
|
66
|
+
esac
|
|
67
|
+
[ -z "${STUB_BRIEF:-}" ] || { mkdir -p docs/design; echo brief > "docs/design/$STUB_BRIEF.md"; }
|
|
68
|
+
printf '{"type":"result","total_cost_usd":0.01,"usage":{"input_tokens":100,"output_tokens":50}}\n'
|
|
69
|
+
STUB
|
|
70
|
+
chmod +x "$tmp/bin/agent-stub"
|
|
71
|
+
cp "$tmp/bin/agent-stub" "$tmp/bin/claude"; cp "$tmp/bin/agent-stub" "$tmp/bin/codex"
|
|
72
|
+
|
|
73
|
+
cat > "$tmp/bin/gh" <<'SH'
|
|
74
|
+
#!/usr/bin/env bash
|
|
75
|
+
{ printf '%s' "$*" | tr '\n' '\036'; echo; } >> "$GH_LOG"
|
|
76
|
+
case "$1 $2" in
|
|
77
|
+
"pr list") case " $* " in *" --head "*) [ -n "$GH_OPEN_URL" ] && echo "$GH_OPEN_URL" ;; esac ;;
|
|
78
|
+
"pr create") echo "https://github.com/o/r/pull/77" ;;
|
|
79
|
+
*) exit 0 ;;
|
|
80
|
+
esac
|
|
81
|
+
SH
|
|
82
|
+
chmod +x "$tmp/bin/gh"
|
|
83
|
+
export PATH="$tmp/bin:$PATH" KIT_WT_INSTALL=0 KIT_STATE_DIR="$tmp/state"
|
|
84
|
+
|
|
85
|
+
git init -q --bare "$tmp/remote.git"
|
|
86
|
+
git clone -q "$tmp/remote.git" "$tmp/work" 2>/dev/null
|
|
87
|
+
cd "$tmp/work" || exit 1
|
|
88
|
+
git config user.email t@t; git config user.name t; git config commit.gpgsign false
|
|
89
|
+
cat > cckit.config.json <<'JSON'
|
|
90
|
+
{"kitVersion":"0.0.0","project":{"name":"x","slug":"x","owner":"o","language":"en"},"profile":"p",
|
|
91
|
+
"github":{"repo":"o/r","owner":"o","baseBranch":"develop","projectsV2":false}}
|
|
92
|
+
JSON
|
|
93
|
+
echo "hello" > page.txt
|
|
94
|
+
printf '.claude/worktrees/\n.cckit/\n' > .gitignore
|
|
95
|
+
git add -A; git commit -q -m init; git branch -M develop; git push -q origin develop 2>/dev/null
|
|
96
|
+
W="$tmp/work"
|
|
97
|
+
|
|
98
|
+
creates() { grep -c '^pr create' "$GH_LOG" || true; }
|
|
99
|
+
rounds() { cat "$tmp/rounds" 2>/dev/null || echo 0; }
|
|
100
|
+
state() { "$CCKIT" task list --all --llm | jq -r --arg id "$1" '.[] | select(.id == $id) | .state'; }
|
|
101
|
+
|
|
102
|
+
# ── usage errors start nothing ──────────────────────────────────────────────────────────────────
|
|
103
|
+
"$CCKIT" task run >/dev/null 2>&1; t "run without an id is a usage error" "$?" "2"
|
|
104
|
+
"$CCKIT" task run x1 --max-iters 0 >/dev/null 2>&1; t "a zero limit is a usage error" "$?" "2"
|
|
105
|
+
"$CCKIT" task run x1 --check >/dev/null 2>&1; t "--check without a value is a usage error" "$?" "2"
|
|
106
|
+
"$CCKIT" task run x1 --nope >/dev/null 2>&1; t "an unknown flag is a usage error" "$?" "2"
|
|
107
|
+
"$CCKIT" task run zz9 >/dev/null 2>&1; t "an unknown task is refused" "$?" "1"
|
|
108
|
+
t "none of them started an agent" "$(rounds)" "0"
|
|
109
|
+
|
|
110
|
+
# ── from a draft to one review ──────────────────────────────────────────────────────────────────
|
|
111
|
+
A="$("$CCKIT" task new --body "Three sections: hero, menu, contact." "Landing page for a bakery" --llm | jq -r .id)"
|
|
112
|
+
out="$("$CCKIT" task run "$A" --check "test -f made.txt" 2>"$tmp/run.err")"; t "run from a draft exits 0" "$?" "0"
|
|
113
|
+
t "stdout is the review link" "$out" "✓ https://github.com/o/r/pull/77"
|
|
114
|
+
WT="$W/.claude/worktrees/light+$A-landing-page-for-a-bakery"
|
|
115
|
+
BR="light/$A-landing-page-for-a-bakery"
|
|
116
|
+
t "the agent ran once" "$(rounds)" "1"
|
|
117
|
+
t "the agent ran in the task's worktree" "$(cat "$tmp/claude.cwd")" "$WT"
|
|
118
|
+
t "the agent was started headless" "$(cat "$tmp/claude.argv")" "-p --output-format json"
|
|
119
|
+
has "the objective carries the task title" "$(cat "$tmp/claude.prompt")" "Do this task: Landing page for a bakery"
|
|
120
|
+
has "the objective carries the task notes" "$(cat "$tmp/claude.prompt")" "Three sections: hero, menu, contact."
|
|
121
|
+
has "the objective names the task record" "$(cat "$tmp/claude.prompt")" "tasks/$A.md"
|
|
122
|
+
hasnt "a task that is not a page task is not told to use page-design" "$(cat "$tmp/claude.prompt")" "page-design"
|
|
123
|
+
hasnt "and its review has no design section" "$(grep '^pr create' "$GH_LOG")" "## Design"
|
|
124
|
+
hasnt "and no open-the-page item" "$(grep '^pr create' "$GH_LOG")" "Open the page"
|
|
125
|
+
t "exactly one review was opened" "$(creates)" "1"
|
|
126
|
+
has "the review targets the base branch from the task branch" "$(grep '^pr create' "$GH_LOG")" "--base develop --head $BR"
|
|
127
|
+
has "its title ends in the task id" "$(grep '^pr create' "$GH_LOG")" "--title feat: Landing page for a bakery [$A]"
|
|
128
|
+
t "the pushed branch says the task is done" "$(git --git-dir="$tmp/remote.git" show "$BR:tasks/$A.md" | sed -n 3p)" "status: done"
|
|
129
|
+
t "a file the agent left uncommitted is in the review" "$(git --git-dir="$tmp/remote.git" show "$BR:made.txt")" "made in round 1"
|
|
130
|
+
t "the draft moved off the starting checkout" "$([ -f "$W/tasks/$A.md" ] && echo left || echo moved)" "moved"
|
|
131
|
+
t "the task lists as review" "$(state "$A")" "review"
|
|
132
|
+
t "nothing was merged: the base branch is unchanged" "$(git --git-dir="$tmp/remote.git" rev-parse develop)" "$(git rev-parse develop)"
|
|
133
|
+
has "the run says which gate it used" "$(cat "$tmp/run.err")" "gate: test -f made.txt"
|
|
134
|
+
|
|
135
|
+
# ── re-running once the review is open reports it and creates nothing ───────────────────────────
|
|
136
|
+
: > "$GH_LOG"
|
|
137
|
+
out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" task run "$A" 2>"$tmp/rerun.err")"; t "a re-run exits 0" "$?" "0"
|
|
138
|
+
t "a re-run prints the open review" "$out" "✓ https://github.com/o/r/pull/77"
|
|
139
|
+
t "a re-run starts no agent" "$(rounds)" "1"
|
|
140
|
+
t "a re-run opens no second review" "$(creates)" "0"
|
|
141
|
+
has "a re-run says no round ran" "$(cat "$tmp/rerun.err")" "no agent round"
|
|
142
|
+
out="$(GH_OPEN_URL="https://github.com/o/r/pull/77" "$CCKIT" task run "$A" --llm)"
|
|
143
|
+
t "--llm is one JSON object: verb, ok, id, url" "$(printf '%s' "$out" | jq -r '[.verb, .ok, .id, .url] | join(" ")')" \
|
|
144
|
+
"task run true $A https://github.com/o/r/pull/77"
|
|
145
|
+
|
|
146
|
+
# ── a failing gate opens no review and exits 6 ──────────────────────────────────────────────────
|
|
147
|
+
B="$("$CCKIT" task new "Pricing table" --llm | jq -r .id)"
|
|
148
|
+
: > "$GH_LOG"; rm -f "$tmp/rounds"
|
|
149
|
+
out="$("$CCKIT" task run "$B" --check "echo gate-red; exit 1" 2>&1)"; t "a failing gate exits 6" "$?" "6"
|
|
150
|
+
t "a failing gate opens no review" "$(creates)" "0"
|
|
151
|
+
has "the last line says no review was opened, and why" "$(printf '%s\n' "$out" | tail -n 1)" "no review was opened — the run stopped with exit 6 (reason=check-failed"
|
|
152
|
+
t "the round did run" "$(rounds)" "1"
|
|
153
|
+
t "the task is still doing" "$(state "$B")" "doing"
|
|
154
|
+
WTB="$W/.claude/worktrees/light+$B-pricing-table"
|
|
155
|
+
t "the work is kept on the task branch" "$(git -C "$WTB" log -1 --format=%s)" "round 1"
|
|
156
|
+
t "the branch copy does not say done" "$(git -C "$WTB" show "HEAD:tasks/$B.md" | sed -n 3p)" "status: todo"
|
|
157
|
+
|
|
158
|
+
# ── the stopped run is discarded; a round that changed nothing opens no review ──────────────────
|
|
159
|
+
out="$(STUB_MODE=idle "$CCKIT" task run "$B" --llm 2>/dev/null)"; t "a round that changed nothing exits 5, not the refusal 2" "$?" "5"
|
|
160
|
+
t "the stopped earlier run did not block the new one" "$(rounds)" "2"
|
|
161
|
+
t "--llm reports the failure" "$(printf '%s' "$out" | jq -r '[.verb, .ok, .id, .url] | join(" ")')" "task run false $B "
|
|
162
|
+
has "the detail carries the reason" "$(printf '%s' "$out" | jq -r .detail)" "reason=no-progress"
|
|
163
|
+
has "and says how to retry" "$(printf '%s' "$out" | jq -r .detail)" "cckit task run $B"
|
|
164
|
+
t "a no-change round opens no review" "$(creates)" "0"
|
|
165
|
+
|
|
166
|
+
# ── gate precedence: tasks.check from the config, --check over it, --no-finish ──────────────────
|
|
167
|
+
jq --arg c "echo config-gate > '$tmp/gate.ran'" '.tasks = {check: $c}' "$W/cckit.config.json" > "$tmp/check.config.json"
|
|
168
|
+
C="$("$CCKIT" task new "Footer links" --llm | jq -r .id)"
|
|
169
|
+
: > "$GH_LOG"
|
|
170
|
+
out="$(KIT_CONFIG="$tmp/check.config.json" "$CCKIT" task run "$C" --no-finish --agent codex --max-seconds 60 2>"$tmp/nf.err")"
|
|
171
|
+
t "--no-finish exits 0" "$?" "0"
|
|
172
|
+
WTC="$W/.claude/worktrees/light+$C-footer-links"
|
|
173
|
+
t "--no-finish prints worktree|branch|id" "$out" "$WTC|light/$C-footer-links|$C"
|
|
174
|
+
t "with no --check the gate is tasks.check" "$(cat "$tmp/gate.ran" 2>/dev/null)" "config-gate"
|
|
175
|
+
t "--agent picks the CLI" "$(cat "$tmp/codex.cwd" 2>/dev/null)" "$WTC"
|
|
176
|
+
t "--no-finish opens no review" "$(creates)" "0"
|
|
177
|
+
t "--no-finish leaves the task doing" "$(state "$C")" "doing"
|
|
178
|
+
has "--no-finish names the command that sends it for review" "$(cat "$tmp/nf.err")" "cckit task finish $C"
|
|
179
|
+
rm -f "$tmp/gate.ran"
|
|
180
|
+
out="$(KIT_CONFIG="$tmp/check.config.json" "$CCKIT" task run "$C" --check "true" 2>/dev/null)"; t "a second run of the same task exits 0" "$?" "0"
|
|
181
|
+
t "--check wins over tasks.check" "$([ -f "$tmp/gate.ran" ] && echo config || echo flag)" "flag"
|
|
182
|
+
t "that run opens the review" "$(creates)" "1"
|
|
183
|
+
D="$("$CCKIT" task new "Contact form" --llm | jq -r .id)"
|
|
184
|
+
"$CCKIT" task run "$D" --no-finish >/dev/null 2>"$tmp/none.err"; t "a run with no gate anywhere exits 0" "$?" "0"
|
|
185
|
+
has "and says there is no gate" "$(cat "$tmp/none.err")" "gate: none"
|
|
186
|
+
|
|
187
|
+
# ── page tasks (#504) ───────────────────────────────────────────────────────────────────────────
|
|
188
|
+
body() { grep '^pr create' "$GH_LOG" | tail -n 1; }
|
|
189
|
+
sfile() { printf '%s/state/autopilot/light_%s-%s.json' "$tmp" "$1" "$2"; }
|
|
190
|
+
|
|
191
|
+
# kind `page`: the objective names the skill, the run records skills, the review lists exactly the
|
|
192
|
+
# ones whose call returned without an error. The agent's own sentence ("I used impeccable,
|
|
193
|
+
# emil-design-eng and web-design-guidelines") is in the output and must not reach the review.
|
|
194
|
+
P="$("$CCKIT" task new --kind page "Bakery landing" --llm | jq -r .id)"
|
|
195
|
+
: > "$GH_LOG"
|
|
196
|
+
out="$(STUB_SKILLS="impeccable page-design concrete emil-design-eng!" STUB_BRIEF="$P" "$CCKIT" task run "$P" 2>"$tmp/page.err")"
|
|
197
|
+
t "a page task run exits 0" "$?" "0"
|
|
198
|
+
t "a page task starts claude with event output" "$(cat "$tmp/claude.argv")" "-p --output-format stream-json --verbose"
|
|
199
|
+
has "the objective names the page-design skill" "$(cat "$tmp/claude.prompt")" 'load the `page-design` skill'
|
|
200
|
+
has "the objective names the design file" "$(cat "$tmp/claude.prompt")" "docs/design/$P.md"
|
|
201
|
+
has "the objective forbids live mode" "$(cat "$tmp/claude.prompt")" 'do not start the live mode of `impeccable`'
|
|
202
|
+
t "the state file holds the loaded skills, and only those" \
|
|
203
|
+
"$(jq -c '.skills | [.loaded, .complete]' "$(sfile "$P" bakery-landing)")" '[["concrete","impeccable","page-design"],true]'
|
|
204
|
+
has "the review lists exactly the design skills that loaded" "$(body)" "Design skills loaded in this run: page-design, impeccable."
|
|
205
|
+
has "a skill whose call failed is listed as not loaded" "$(body)" "Design skills not loaded in this run: emil-design-eng, web-design-guidelines."
|
|
206
|
+
has "other loaded skills are listed apart" "$(body)" "Other skills loaded in this run: concrete."
|
|
207
|
+
hasnt "the agent's own claim is not in the review" "$(body)" "I used impeccable"
|
|
208
|
+
has "the review says where the list comes from" "$(body)" "Read from the events the agent CLI (claude) printed during the run"
|
|
209
|
+
has "the review asks the reviewer to open the page" "$(body)" "- [ ] Open the page in a browser and compare it with the design brief"
|
|
210
|
+
has "the review names the design brief" "$(body)" "Design brief and self-review: \`docs/design/$P.md\`."
|
|
211
|
+
has "a project without the skill is told so" "$(cat "$tmp/page.err")" "the page-design skill is not in this project"
|
|
212
|
+
t "usage is still read from the event output" "$(jq -r '.usage.tokens' "$(sfile "$P" bakery-landing)")" "150"
|
|
213
|
+
|
|
214
|
+
# A run that loaded no skill says so; so does a missing brief.
|
|
215
|
+
Q="$("$CCKIT" task new --kind page "Menu page" --llm | jq -r .id)"
|
|
216
|
+
: > "$GH_LOG"
|
|
217
|
+
mkdir -p "$W/.claude/skills/page-design"; echo x > "$W/.claude/skills/page-design/SKILL.md"
|
|
218
|
+
git -C "$W" add -A; git -C "$W" commit -q -m "add the skill"; git -C "$W" push -q origin develop 2>/dev/null
|
|
219
|
+
STUB_SKILLS="" "$CCKIT" task run "$Q" >/dev/null 2>"$tmp/q.err"; t "a page run that loads nothing still exits 0" "$?" "0"
|
|
220
|
+
has "a run that loaded no design skill says so" "$(body)" "No design skill was loaded in this run."
|
|
221
|
+
has "and names all four as not loaded" "$(body)" "Design skills not loaded in this run: page-design, impeccable, emil-design-eng, web-design-guidelines."
|
|
222
|
+
hasnt "and lists none as loaded" "$(body)" "Design skills loaded in this run"
|
|
223
|
+
has "a missing brief is said, not assumed" "$(body)" "No design brief is in this change: \`docs/design/$Q.md\` was not written."
|
|
224
|
+
hasnt "a project that has the skill gets no warning" "$(cat "$tmp/q.err")" "is not in this project"
|
|
225
|
+
|
|
226
|
+
# No event in the output: the list is not known, which is not the same as empty.
|
|
227
|
+
R="$("$CCKIT" task new --kind page "About page" --llm | jq -r .id)"
|
|
228
|
+
: > "$GH_LOG"
|
|
229
|
+
STUB_EVENTS=0 "$CCKIT" task run "$R" >/dev/null 2>&1; t "a run with no event output exits 0" "$?" "0"
|
|
230
|
+
has "no event output reads as not known" "$(body)" "Which skills were loaded is not known: the agent CLI printed no event output"
|
|
231
|
+
hasnt "and never as 'none was loaded'" "$(body)" "No design skill was loaded"
|
|
232
|
+
t "the state file marks the list incomplete" "$(jq -r '.skills.complete' "$(sfile "$R" about-page)")" "false"
|
|
233
|
+
|
|
234
|
+
# The config rule: tasks.design makes every task a page task; `task finish` by hand reads the
|
|
235
|
+
# same record.
|
|
236
|
+
jq '.tasks = {design: true}' "$W/cckit.config.json" > "$tmp/design.config.json"
|
|
237
|
+
S="$("$CCKIT" task new "Pricing section" --llm | jq -r .id)"
|
|
238
|
+
: > "$GH_LOG"
|
|
239
|
+
KIT_CONFIG="$tmp/design.config.json" STUB_SKILLS="page-design" "$CCKIT" task run "$S" --no-finish >/dev/null 2>&1
|
|
240
|
+
t "tasks.design: a plain task runs as a page task" "$(cat "$tmp/claude.argv")" "-p --output-format stream-json --verbose"
|
|
241
|
+
has "tasks.design: the objective names page-design" "$(cat "$tmp/claude.prompt")" 'load the `page-design` skill'
|
|
242
|
+
KIT_CONFIG="$tmp/design.config.json" "$CCKIT" task finish "$S" "by hand" --all >/dev/null 2>&1; t "finish by hand exits 0" "$?" "0"
|
|
243
|
+
has "finish by hand prints the recorded skills" "$(body)" "Design skills loaded in this run: page-design."
|
|
244
|
+
"$CCKIT" task run "$D" >/dev/null 2>&1
|
|
245
|
+
hasnt "without tasks.design the same kind of task is not a page task" "$(body)" "## Design"
|
|
246
|
+
|
|
247
|
+
# A page task finished with no run on record does not get a list.
|
|
248
|
+
T="$("$CCKIT" task new --kind page "Contact page" --llm | jq -r .id)"
|
|
249
|
+
"$CCKIT" task start "$T" >/dev/null 2>&1
|
|
250
|
+
: > "$GH_LOG"
|
|
251
|
+
"$CCKIT" task finish "$T" "written by hand" --all >/dev/null 2>&1; t "a page task finished by hand exits 0" "$?" "0"
|
|
252
|
+
has "with no run on record the list is not known" "$(body)" 'Which skills were loaded is not known: no `cckit task run` is recorded for this task.'
|
|
253
|
+
|
|
254
|
+
[ "$fail" -eq 0 ] && echo "PASS light-task-run-test" || echo "FAIL light-task-run-test"
|
|
255
|
+
exit "$fail"
|