@jeiemgi/cckit 0.10.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.
- package/.claude-plugin/plugin.json +1 -1
- package/AGENTS.md +136 -127
- package/README.md +66 -43
- package/bin/cckit +151 -181
- package/cckit.config.json +1 -4
- package/package.json +1 -1
- package/scripts/advisor-test.sh +55 -0
- package/scripts/autopilot-run-test.sh +20 -12
- package/scripts/autopilot-run.sh +9 -1
- package/scripts/autopilot-test.sh +29 -13
- package/scripts/autopilot.sh +4 -4
- package/scripts/benchmark/verb-timings-test.sh +4 -0
- package/scripts/benchmark/verb-timings.sh +16 -5
- package/scripts/capture-project-ids.sh +23 -1
- package/scripts/check.sh +25 -0
- package/scripts/content-skills-test.sh +1 -1
- package/scripts/contribute.sh +8 -3
- package/scripts/copilot-loop-test.sh +66 -81
- package/scripts/exec-targets-test.sh +20 -0
- package/scripts/force-push-fence-test.sh +44 -0
- package/scripts/force-push-fence.baseline +1 -0
- package/scripts/force-push-fence.sh +51 -0
- package/scripts/forge-fence-test.sh +69 -0
- package/scripts/forge-fence.baseline +2 -0
- package/scripts/forge-fence.sh +76 -0
- package/scripts/forge-report-test.sh +100 -0
- package/scripts/forge-report.sh +176 -0
- package/scripts/init-guided-test.sh +94 -82
- package/scripts/init.sh +12 -7
- package/scripts/install-test.sh +26 -0
- package/scripts/install.sh +7 -0
- package/scripts/instruction-budget-baseline.txt +1 -1
- package/scripts/kit-doctor-test.sh +60 -12
- package/scripts/kit-doctor.sh +170 -77
- package/scripts/lib/agent-resolve-test.sh +2 -0
- package/scripts/lib/agent-resolve.sh +15 -8
- package/scripts/lib/board-view.sh +3 -3
- package/scripts/lib/captain.sh +37 -8
- package/scripts/lib/content-kinds-gc-test.sh +22 -21
- package/scripts/lib/copilot-test.sh +20 -11
- package/scripts/lib/copilot.sh +19 -13
- package/scripts/lib/effort-close-subs-test.sh +96 -0
- package/scripts/lib/effort-dispatch-test.sh +5 -3
- package/scripts/lib/effort-metrics-test.sh +7 -12
- package/scripts/lib/effort-metrics.sh +17 -46
- package/scripts/lib/effort-ops-test.sh +261 -167
- package/scripts/lib/effort-ops.sh +449 -171
- package/scripts/lib/effort-parity-test.sh +57 -62
- package/scripts/lib/effort-plan-test.sh +56 -54
- package/scripts/lib/effort-plan.sh +14 -7
- package/scripts/lib/effort-review-test.sh +107 -0
- package/scripts/lib/effort-review.sh +93 -0
- package/scripts/lib/effort-slug-test.sh +34 -14
- package/scripts/lib/effort-slug.sh +13 -13
- package/scripts/lib/effort.sh +58 -80
- package/scripts/lib/forge-github.sh +260 -0
- package/scripts/lib/forge-none.sh +24 -0
- package/scripts/lib/forge-test.sh +186 -0
- package/scripts/lib/forge.sh +133 -0
- package/scripts/lib/gh-board-add-test.sh +118 -0
- package/scripts/lib/gh-project-test.sh +151 -31
- package/scripts/lib/gh-project.sh +139 -11
- package/scripts/lib/gh-rest-test.sh +63 -118
- package/scripts/lib/gh-rest.sh +275 -52
- package/scripts/lib/git-core-test.sh +128 -0
- package/scripts/lib/grill-record-test.sh +49 -0
- package/scripts/lib/grill-record.sh +88 -0
- package/scripts/lib/handoff.sh +1 -1
- package/scripts/lib/init-github.sh +38 -13
- package/scripts/lib/kinds-test.sh +13 -16
- package/scripts/lib/kit-brief-test.sh +51 -10
- package/scripts/lib/kit-brief.sh +103 -18
- package/scripts/lib/kit-gc-test.sh +90 -109
- package/scripts/lib/kit-gc.sh +19 -22
- package/scripts/lib/kit-hotfix.sh +18 -16
- package/scripts/lib/kit-interview.sh +6 -0
- package/scripts/lib/kit-lib-test.sh +1 -1
- package/scripts/lib/kit-lib.sh +7 -7
- package/scripts/lib/kit-msg.sh +3 -3
- package/scripts/lib/kit-status.sh +19 -14
- package/scripts/lib/kit-task-ops-test.sh +20 -1
- package/scripts/lib/kit-task-ops.sh +177 -94
- package/scripts/lib/kto-hotfix-test.sh +53 -58
- package/scripts/lib/kto-task-close-test.sh +28 -27
- package/scripts/lib/kto-task-new-test.sh +55 -48
- package/scripts/lib/kto-task-pr-merge-test.sh +77 -41
- package/scripts/lib/kto-task-pr-test.sh +30 -34
- package/scripts/lib/light-task-run-test.sh +19 -15
- package/scripts/lib/light-task-test.sh +34 -29
- package/scripts/lib/light-task.sh +24 -13
- package/scripts/lib/loose-issues.sh +65 -0
- package/scripts/lib/naming-test.sh +112 -0
- package/scripts/lib/naming-verbs-test.sh +126 -0
- package/scripts/lib/naming.sh +172 -0
- package/scripts/lib/next-test.sh +27 -22
- package/scripts/lib/next.sh +13 -7
- package/scripts/lib/orchestration-runtime-test.sh +11 -8
- package/scripts/lib/plan-machine.sh +22 -16
- package/scripts/lib/plan-next.sh +4 -4
- package/scripts/lib/pr-evidence-test.sh +63 -74
- package/scripts/lib/pr-evidence.sh +15 -12
- package/scripts/lib/qa-lane-test.sh +59 -27
- package/scripts/lib/qa-lane.sh +14 -6
- package/scripts/lib/review-page-test.sh +34 -25
- package/scripts/lib/review-page.sh +10 -4
- package/scripts/lib/spec-lint-test.sh +63 -0
- package/scripts/lib/spec-lint.sh +95 -0
- package/scripts/lib/sprint-test.sh +96 -0
- package/scripts/lib/sprint.sh +216 -0
- package/scripts/lib/stage-receipt-test.sh +169 -19
- package/scripts/lib/stage-receipt.sh +195 -10
- package/scripts/lib/test-forge-shim.sh +115 -0
- package/scripts/lib/verbs.sh +105 -0
- package/scripts/lib/verbs.tsv +92 -0
- package/scripts/lib/version-bump-test.sh +20 -0
- package/scripts/lib/version-bump.sh +4 -2
- package/scripts/lib/worker-brief-test.sh +1 -1
- package/scripts/lib/worker-brief.sh +1 -1
- package/scripts/lib/worktree-issue-test.sh +24 -19
- package/scripts/lib/worktree-issue.sh +10 -10
- package/scripts/lib/worktree-start-test.sh +13 -16
- package/scripts/lib/worktree-start.sh +57 -7
- package/scripts/loose-issues-test.sh +102 -0
- package/scripts/loose-issues.baseline +5 -0
- package/scripts/marketing-walkthrough-test.sh +25 -30
- package/scripts/night-grant.sh +14 -8
- package/scripts/night-run.mjs +1 -1
- package/scripts/orchestrate-test.sh +27 -31
- package/scripts/orchestrate.sh +9 -3
- package/scripts/portable-test.sh +37 -36
- package/scripts/publish.sh +9 -3
- package/scripts/setup-labels.sh +23 -12
- package/scripts/setup-milestones.sh +8 -2
- package/scripts/status-test.sh +39 -33
- package/scripts/status.sh +12 -6
- package/scripts/task-sync-test.sh +75 -32
- package/scripts/task-sync.sh +97 -6
- package/scripts/terms-check-test.sh +191 -0
- package/scripts/terms-check.sh +242 -0
- package/scripts/verbs-gen.sh +43 -0
- package/scripts/verbs-help-test.sh +61 -0
- package/scripts/verbs-ratchet-test.sh +69 -0
- package/scripts/verbs-ratchet.sh +34 -0
- package/scripts/verbs-test.sh +120 -0
- package/scripts/verbs.baseline +5 -0
- package/skills/kit-add/SKILL.md +2 -1
- package/skills/kit-advisor/SKILL.md +75 -0
- package/skills/kit-advisor/references/close.md +53 -0
- package/skills/kit-advisor/references/grill.md +69 -0
- package/skills/kit-advisor/references/orchestrate.md +56 -0
- package/skills/kit-advisor/references/plan.md +64 -0
- package/skills/kit-advisor/references/review.md +47 -0
- package/skills/kit-advisor/references/step-report.md +61 -0
- package/skills/kit-annotate/SKILL.md +1 -0
- package/skills/kit-autopilot/SKILL.md +2 -1
- package/skills/kit-cleanup/SKILL.md +3 -2
- package/skills/kit-contribute/SKILL.md +1 -0
- package/skills/kit-customize/SKILL.md +1 -0
- package/skills/kit-dev/SKILL.md +1 -0
- package/skills/kit-digest/SKILL.md +1 -0
- package/skills/kit-docs-writer/SKILL.md +4 -3
- package/skills/kit-effort-close/SKILL.md +18 -9
- package/skills/kit-effort-new/SKILL.md +12 -8
- package/skills/kit-effort-pr/SKILL.md +8 -7
- package/skills/kit-effort-start/SKILL.md +1 -0
- package/skills/kit-gc/SKILL.md +1 -0
- package/skills/kit-next/SKILL.md +8 -7
- package/skills/kit-onboard/SKILL.md +1 -0
- package/skills/kit-page/SKILL.md +1 -0
- package/skills/kit-plan-next/SKILL.md +11 -11
- package/skills/kit-security-sweep/SKILL.md +1 -0
- package/skills/kit-ship/SKILL.md +1 -0
- package/skills/kit-status/SKILL.md +6 -5
- package/skills/kit-task-close/SKILL.md +1 -0
- package/skills/kit-task-new/SKILL.md +1 -0
- package/skills/kit-task-pr/SKILL.md +1 -0
- package/skills/kit-task-pr-auto/SKILL.md +2 -1
- package/skills/kit-task-pr-merge/SKILL.md +4 -3
- package/skills/kit-task-start/SKILL.md +1 -0
- package/skills/kit-task-sync/SKILL.md +3 -0
- package/skills/kit-ux-audit/SKILL.md +1 -0
- package/skills/routing.yaml +124 -0
- package/templates/hooks/kit-mail-check.sh.tmpl +1 -1
- package/templates/instructions.md.tmpl +3 -3
- package/templates/rules/authoring.md +7 -3
- package/templates/rules/delegation-brief.md +4 -0
- package/templates/rules/effort-model.md +34 -31
- package/templates/rules/gate-and-review.md +1 -1
- package/templates/rules/merge-safety.md +9 -7
- package/templates/rules/naming-and-ids.md +20 -24
- package/templates/rules/plan-next.md +5 -5
- package/templates/skills/campaign/SKILL.md +2 -2
- package/scripts/lib/engine-adapter.sh +0 -93
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
# copilot-test.sh — self-test for copilot.sh under bash AND zsh.
|
|
3
3
|
# Network-free: covers the seed composer, the per-adapter dispatch wording, adapter resolution, and
|
|
4
|
-
# the human brief of copilot_brief run under `set -e` against a stubbed plan machine
|
|
5
|
-
# (#316). Run: bash scripts/lib/copilot-test.sh
|
|
4
|
+
# the human brief of copilot_brief run under `set -e` against a stubbed plan machine, the forge shim
|
|
5
|
+
# and a stub jq (#316). Run: bash scripts/lib/copilot-test.sh
|
|
6
6
|
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
7
|
|
|
8
8
|
dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
|
@@ -13,7 +13,9 @@ if [ -n "${CP_TEST_INNER:-}" ]; then
|
|
|
13
13
|
has() { case "$2" in *"$3"*) ;; *) echo "FAIL($CP_TEST_INNER): $1 missing '[$3]'"; fail=1 ;; esac; }
|
|
14
14
|
|
|
15
15
|
seed="$(_copilot_seed 42 'wire the thing')"
|
|
16
|
-
has "seed
|
|
16
|
+
has "seed reads the issue with cckit brief" "$seed" 'cckit brief 42'
|
|
17
|
+
no0() { case "$2" in *"$3"*) echo "FAIL($CP_TEST_INNER): $1 has unexpected '[$3]'"; fail=1 ;; esac; }
|
|
18
|
+
no0 "seed names no gh subcommand" "$seed" 'gh issue view'
|
|
17
19
|
has "seed has title" "$seed" 'implement "wire the thing"'
|
|
18
20
|
has "seed has pr verb" "$seed" 'cckit pr 42'
|
|
19
21
|
has "seed has close verb" "$seed" 'cckit close 42'
|
|
@@ -50,28 +52,30 @@ if [ -n "${CP_TEST_INNER:-}" ]; then
|
|
|
50
52
|
# copilot_brief kills the verb with no output. Drive the real function in a child shell with
|
|
51
53
|
# errexit on. copilot_brief sources plan-machine.sh + render.sh from its own directory, so the
|
|
52
54
|
# sandbox holds the real copilot.sh + render.sh + the two adapter-resolution libs beside a stub
|
|
53
|
-
# plan machine that emits two rows.
|
|
55
|
+
# plan machine that emits two rows, plus the forge port libs copilot.sh sources beside itself.
|
|
54
56
|
box="$(mktemp -d "${TMPDIR:-/tmp}/copilot-test.XXXXXX")"
|
|
55
57
|
mkdir -p "$box/bin"
|
|
56
|
-
cp "$dir/copilot.sh" "$dir/render.sh" "$dir/adapter-select.sh" "$dir/config-path.sh"
|
|
58
|
+
cp "$dir/copilot.sh" "$dir/render.sh" "$dir/adapter-select.sh" "$dir/config-path.sh" \
|
|
59
|
+
"$dir/gh-rest.sh" "$dir/forge.sh" "$dir/forge-github.sh" "$dir/forge-none.sh" "$box/"
|
|
57
60
|
cat > "$box/plan-machine.sh" <<'STUB'
|
|
58
61
|
plan_machine() {
|
|
59
62
|
printf '0\t-\t7\tS\t-\t[Effort 5] 1 · first thing\n'
|
|
60
63
|
printf '1\t-\t8\tM\t-\tsecond thing\n'
|
|
61
64
|
}
|
|
62
65
|
STUB
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
# The forge shim's gh fails on any subcommand; jq is a stub that exits 0 (the brief needs neither).
|
|
67
|
+
. "$dir/test-forge-shim.sh"; forge_shim_install "$box/bin"
|
|
68
|
+
printf '#!/bin/sh\nexit 0\n' > "$box/bin/jq"; chmod +x "$box/bin/jq"
|
|
66
69
|
brief_run() { # brief_run [copilot_brief args…] — prints the brief, returns the child's rc
|
|
67
70
|
( cd "$box" && PATH="$box/bin:$PATH" CCKIT_NO_GLOW=1 CCKIT_OUTPUT=human COPILOT_REPO=o/r \
|
|
71
|
+
GH_LOG="$box/gh.log" GH_TOKEN=test-token CCKIT_FORGE="${CCKIT_FORGE:-github}" \
|
|
68
72
|
"$CP_TEST_INNER" -c 'set -e; . ./copilot.sh; copilot_brief "$@"' copilot "$@" )
|
|
69
73
|
}
|
|
70
74
|
hasnt() { case "$2" in *"$3"*) echo "FAIL($CP_TEST_INNER): $1 has '[$3]'"; fail=1 ;; esac; }
|
|
71
75
|
|
|
72
76
|
brief="$(brief_run)"; brc=$?
|
|
73
77
|
[ "$brc" -eq 0 ] || { echo "FAIL($CP_TEST_INNER): brief without --effort rc=$brc (want 0)"; fail=1; }
|
|
74
|
-
has "brief has heading" "$brief" '# cckit wave — o/r'
|
|
78
|
+
has "brief has heading" "$brief" '# cckit effort plan --wave — o/r'
|
|
75
79
|
has "brief lists wave-0 issue" "$brief" '### #7 · [S] · first thing'
|
|
76
80
|
has "brief has watch line" "$brief" 'cckit watch --merge'
|
|
77
81
|
has "brief carries the default adapter dispatch" "$brief" '### Claude Code — spawn 1 parallel Task subagent(s)'
|
|
@@ -80,9 +84,14 @@ STUB
|
|
|
80
84
|
|
|
81
85
|
brief="$(brief_run --effort 5)"; brc=$?
|
|
82
86
|
[ "$brc" -eq 0 ] || { echo "FAIL($CP_TEST_INNER): brief with --effort rc=$brc (want 0)"; fail=1; }
|
|
83
|
-
has "effort brief heading" "$brief" '# cckit wave — o/r · effort #5'
|
|
87
|
+
has "effort brief heading" "$brief" '# cckit effort plan --wave — o/r · effort #5'
|
|
84
88
|
has "effort brief watch suffix" "$brief" 'cckit watch --merge --effort 5'
|
|
85
|
-
has "effort brief wave suffix" "$brief" 'cckit wave --effort 5'
|
|
89
|
+
has "effort brief wave suffix" "$brief" 'cckit effort plan --wave --effort 5'
|
|
90
|
+
eq "the brief ran no gh subcommand" "$(c="$(grep -c '^GH-SUBCOMMAND' "$box/gh.log" 2>/dev/null)"; echo "${c:-0}")" "0"
|
|
91
|
+
# no forge configured: the verb refuses with the one line naming it (forge_need), rc 1.
|
|
92
|
+
brief="$(CCKIT_FORGE=none brief_run 2>&1)"; brc=$?
|
|
93
|
+
eq "no forge: rc 1" "$brc" "1"
|
|
94
|
+
has "no forge: the refusal names the verb" "$brief" 'cckit effort plan --wave: needs a forge (GitHub) and none is configured'
|
|
86
95
|
rm -rf "$box"
|
|
87
96
|
|
|
88
97
|
if [ "$fail" -eq 0 ]; then echo "PASS($CP_TEST_INNER): copilot seed composer + adapter dispatch + brief under set -e"; fi
|
package/scripts/lib/copilot.sh
CHANGED
|
@@ -12,15 +12,21 @@
|
|
|
12
12
|
# how this runtime starts N isolated workers — is chosen per adapter: Claude Code fans out Task
|
|
13
13
|
# subagents with worktree isolation; for Codex, cckit creates the worktrees (`cckit orchestrate`).
|
|
14
14
|
#
|
|
15
|
-
# cckit wave brief for the open board: wave 0 fan-out + the loop
|
|
16
|
-
# cckit wave --effort <N> brief scoped to effort #N's sub-issues
|
|
17
|
-
# cckit wave --cap <K> session ctx budget per wave (passed to the plan machine)
|
|
18
|
-
# cckit wave --adapter <claude|codex|both> dispatch wording (default: the project's adapters)
|
|
19
|
-
# cckit wave --llm the fan-out as TOON rows (wave,number,ctx,prompt) for an agent
|
|
15
|
+
# cckit effort plan --wave brief for the open board: wave 0 fan-out + the loop
|
|
16
|
+
# cckit effort plan --wave --effort <N> brief scoped to effort #N's sub-issues
|
|
17
|
+
# cckit effort plan --wave --cap <K> session ctx budget per wave (passed to the plan machine)
|
|
18
|
+
# cckit effort plan --wave --adapter <claude|codex|both> dispatch wording (default: the project's adapters)
|
|
19
|
+
# cckit effort plan --wave --llm the fan-out as TOON rows (wave,number,ctx,prompt) for an agent
|
|
20
20
|
#
|
|
21
21
|
# Requires: gh, jq (via the plan machine). bash 3.2 / zsh compatible.
|
|
22
22
|
# errors: strict — refuses to emit a brief without gh + jq
|
|
23
23
|
|
|
24
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
25
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
26
|
+
# shellcheck source=/dev/null
|
|
27
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
28
|
+
fi
|
|
29
|
+
|
|
24
30
|
COPILOT_REPO="${COPILOT_REPO:-${KIT_REPO:-}}"
|
|
25
31
|
# Resolved at source time: inside a function zsh's $0 is the function's name, not this file.
|
|
26
32
|
_COPILOT_DIR="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)"
|
|
@@ -29,7 +35,7 @@ _COPILOT_DIR="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/nu
|
|
|
29
35
|
# Runtime-neutral on purpose: it is wave data, so it must read the same whichever agent receives it.
|
|
30
36
|
_copilot_seed() {
|
|
31
37
|
local num="$1" title="$2"
|
|
32
|
-
printf 'You are a worker in a cckit wave run — NO human is present, so never ask: decide autonomously and apply effort proportional to the task. Your worktree and branch for issue #%s are already isolated. Do:
|
|
38
|
+
printf 'You are a worker in a cckit effort plan --wave run — NO human is present, so never ask: decide autonomously and apply effort proportional to the task. Your worktree and branch for issue #%s are already isolated. Do: read the issue with `cckit brief %s`, implement "%s", run `bash scripts/check.sh` until green, then open the PR with `cckit pr %s "<summary>"`. If it is a no-op, run `cckit close %s "<reason>"` with why. Return a one-line result.' \
|
|
33
39
|
"$num" "$num" "$title" "$num" "$num"
|
|
34
40
|
}
|
|
35
41
|
|
|
@@ -64,11 +70,11 @@ _copilot_dispatch() {
|
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
copilot_brief() {
|
|
67
|
-
|
|
73
|
+
forge_need "effort plan --wave" || return 1; command -v jq >/dev/null 2>&1 || { echo "copilot: needs jq" >&2; return 1; }
|
|
68
74
|
local repo="$COPILOT_REPO" out="${CCKIT_OUTPUT:-human}" effort="" cap="" adapter_arg="" adapters planargs=()
|
|
69
75
|
while [ "$#" -gt 0 ]; do
|
|
70
76
|
case "$1" in
|
|
71
|
-
--llm|--output=json) out="json"; shift ;;
|
|
77
|
+
--json|--llm|--output=json) out="json"; shift ;;
|
|
72
78
|
--effort) effort="$2"; planargs+=(--effort "$2"); shift 2 ;;
|
|
73
79
|
--effort=*) effort="${1#*=}"; planargs+=(--effort "${1#*=}"); shift ;;
|
|
74
80
|
--cap) cap="$2"; planargs+=(--cap "$2"); shift 2 ;;
|
|
@@ -105,7 +111,7 @@ copilot_brief() {
|
|
|
105
111
|
json="$(printf '%s\n' "$wave0" | awk -F'\t' '{print $3"\t"$4"\t"$6}' \
|
|
106
112
|
| while IFS="$(printf '\t')" read -r num ctx title; do
|
|
107
113
|
[ -n "$num" ] || continue
|
|
108
|
-
disp="$(printf '%s' "$title" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
|
|
114
|
+
disp="$(printf '%s' "$title" | sed -E 's/^\[E[0-9]+(\.[0-9]+)?\] +//; s/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
|
|
109
115
|
printf '%s\t%s\t%s\n' "$num" "$ctx" "$(_copilot_seed "$num" "$disp")"
|
|
110
116
|
done \
|
|
111
117
|
| jq -R -s '[ split("\n")[] | select(length>0) | split("\t")
|
|
@@ -127,7 +133,7 @@ copilot_brief() {
|
|
|
127
133
|
if [ -n "$effort" ]; then esfx=" --effort $effort"; fi
|
|
128
134
|
nums="$(printf '%s\n' "$wave0" | awk -F'\t' '$3 != "" { printf "%s%s", sep, $3; sep = " " }')"
|
|
129
135
|
{
|
|
130
|
-
printf '# cckit wave — %s%s\n' "$repo" "$([ -n "$effort" ] && echo " · effort #$effort")"
|
|
136
|
+
printf '# cckit effort plan --wave — %s%s\n' "$repo" "$([ -n "$effort" ] && echo " · effort #$effort")"
|
|
131
137
|
printf '\nThe plan machine laid out %s wave(s). You are the orchestrator: fan wave 0 out as parallel\nworkers, gate + merge with the captain, then re-run this brief for the next wave.\n' "$((waves_total + 1))"
|
|
132
138
|
|
|
133
139
|
printf '\n## Wave 0 — %s parallel worker(s)\n\n' "$n0"
|
|
@@ -136,7 +142,7 @@ copilot_brief() {
|
|
|
136
142
|
printf '%s\n' "$wave0" | awk -F'\t' '{print $3"\t"$4"\t"$6}' \
|
|
137
143
|
| while IFS="$(printf '\t')" read -r num ctx title; do
|
|
138
144
|
[ -n "$num" ] || continue
|
|
139
|
-
disp="$(printf '%s' "$title" | sed -E 's/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
|
|
145
|
+
disp="$(printf '%s' "$title" | sed -E 's/^\[E[0-9]+(\.[0-9]+)?\] +//; s/^\[Effort( [0-9]+)?\] [0-9]+ · ?//; s/^\[[A-Za-z]+\] //')"
|
|
140
146
|
printf '### #%s · [%s] · %s\n\n' "$num" "$ctx" "$disp"
|
|
141
147
|
printf '> %s\n\n' "$(_copilot_seed "$num" "$disp")"
|
|
142
148
|
done
|
|
@@ -145,8 +151,8 @@ copilot_brief() {
|
|
|
145
151
|
printf '1. When the wave-0 workers have opened their PRs, gate + merge them:\n'
|
|
146
152
|
printf ' ```\n cckit watch --merge%s\n ```\n' "$esfx"
|
|
147
153
|
printf '2. Merging unblocks the next wave. Re-run this brief to get it:\n'
|
|
148
|
-
printf ' ```\n cckit wave%s\n ```\n' "$esfx"
|
|
149
|
-
printf '3. Repeat until `cckit wave` reports nothing to drive. To let the captain self-pace the\n gate/merge passes, use `cckit watch --loop`'
|
|
154
|
+
printf ' ```\n cckit effort plan --wave%s\n ```\n' "$esfx"
|
|
155
|
+
printf '3. Repeat until `cckit effort plan --wave` reports nothing to drive. To let the captain self-pace the\n gate/merge passes, use `cckit watch --loop`'
|
|
150
156
|
# `/loop` is a Claude Code command; a brief for Codex alone must not name it.
|
|
151
157
|
case " $adapters " in *" claude "*) printf ' (or drive this brief under `/loop` in Claude Code)' ;; esac
|
|
152
158
|
printf '.\n\n'
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# effort-close-subs-test.sh — `cckit effort close` closes only the finished subs (#565, decision 52).
|
|
4
|
+
# Hermetic: the forge shim (test-forge-shim.sh) answers like the REST API and logs `METHOD path {json}`;
|
|
5
|
+
# a throwaway git repo with a bare remote. Run: bash scripts/lib/effort-close-subs-test.sh
|
|
6
|
+
# errors: strict — a test runner: rc 1 on any failed assertion
|
|
7
|
+
set -u
|
|
8
|
+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
. "$ROOT/scripts/lib/test-env.sh" && test_env_seal
|
|
11
|
+
LIB="$ROOT/scripts/lib"
|
|
12
|
+
fail=0
|
|
13
|
+
t() { if [ "$2" = "$3" ]; then echo "ok: $1"; else echo "FAIL: $1 -> got '[$2]' want '[$3]'"; fail=1; fi; }
|
|
14
|
+
tc() { if grep -qE "$2" "$1"; then echo "ok: $3"; else echo "FAIL: $3 (no /$2/ in $1)"; fail=1; fi; }
|
|
15
|
+
command -v jq >/dev/null 2>&1 || { echo "effort-close-subs-test: jq required" >&2; exit 1; }
|
|
16
|
+
command -v git >/dev/null 2>&1 || { echo "effort-close-subs-test: git required" >&2; exit 1; }
|
|
17
|
+
|
|
18
|
+
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|
19
|
+
export GH_LOG="$tmp/gh.log"; export GH_N="$tmp/n"; : > "$GH_LOG"; printf '0' > "$GH_N"
|
|
20
|
+
stub="$tmp/bin"
|
|
21
|
+
# shellcheck source=/dev/null
|
|
22
|
+
. "$LIB/test-forge-shim.sh"; forge_shim_install "$stub"
|
|
23
|
+
export PATH="$stub:$PATH" GH_TOKEN=test-token CCKIT_FORGE=github
|
|
24
|
+
export GH_TITLE="[E66] demo effort" GH_LABELS='[{"name":"kind:task"}]'
|
|
25
|
+
export GH_HEAD="effort/66-demo" GH_BASE="main" GH_MERGEABLE=true
|
|
26
|
+
export GH_BODY='## Goal\nship it\n\n## Spec\n- it ships'
|
|
27
|
+
# Effort #66 has four subs: 601 already closed, 602 open but delivered by a `Closes #602` commit,
|
|
28
|
+
# 603 open but delivered by a commit tagged with its step id [E66.3], 604 open and delivered by
|
|
29
|
+
# nothing — the one that must stay open.
|
|
30
|
+
export GH_FIXTURE="$tmp/fixture.sh"
|
|
31
|
+
cat > "$GH_FIXTURE" <<'SH'
|
|
32
|
+
case "$method $ep" in
|
|
33
|
+
"GET repos/o/r/issues/66/sub_issues")
|
|
34
|
+
out='[{"number":601,"state":"closed","title":"[E66.1] first"},
|
|
35
|
+
{"number":602,"state":"open","title":"[E66.2] second"},
|
|
36
|
+
{"number":603,"state":"open","title":"[E66.3] third"},
|
|
37
|
+
{"number":604,"state":"open","title":"[E66.4] release later"}]' ;;
|
|
38
|
+
esac
|
|
39
|
+
SH
|
|
40
|
+
export KIT_REPO="o/r" EFFORT_REPO="o/r" KIT_BASE_BRANCH="main" KIT_WT_INSTALL=0
|
|
41
|
+
# shellcheck source=/dev/null
|
|
42
|
+
source "$LIB/effort.sh" 2>/dev/null
|
|
43
|
+
# shellcheck source=/dev/null
|
|
44
|
+
source "$LIB/effort-ops.sh"
|
|
45
|
+
|
|
46
|
+
# ── the pure partition ───────────────────────────────────────────────────────────────────────────
|
|
47
|
+
refs="$(printf '#602\nE66.3\n')"
|
|
48
|
+
part="$(printf '%s\n' "601|closed|[E66.1] a" "602|open|[E66.2] b" "603|OPEN|[E66.3] c" "604|open|[E66.4] d" "605|open|[E67.3] e" \
|
|
49
|
+
| _eo_partition_subs 66 "$refs" | tr '\n' ' ')"
|
|
50
|
+
t "partition: closed, #-delivered and step-delivered are done; the rest stay open" "$part" \
|
|
51
|
+
"done|601|closed done|602|open done|603|open open|604|[E66.4] d open|605|[E67.3] e "
|
|
52
|
+
t "partition: no subs → no output" "$(printf '' | _eo_partition_subs 66 "$refs")" ""
|
|
53
|
+
|
|
54
|
+
# ── --help answers without resolving an effort (#578) ─────────────────────────────────────────────
|
|
55
|
+
: > "$GH_LOG"
|
|
56
|
+
h="$(effort_close --help 2>&1)"; rc=$?
|
|
57
|
+
t "effort close --help exits 0" "$rc" "0"
|
|
58
|
+
case "$h" in "cckit effort close"*) echo "ok: effort close --help prints the usage" ;; *) echo "FAIL: effort close --help: $h"; fail=1 ;; esac
|
|
59
|
+
h="$(effort_pr --help 2>&1)"; rc=$?
|
|
60
|
+
t "effort pr --help exits 0" "$rc" "0"
|
|
61
|
+
case "$h" in "cckit effort pr"*) echo "ok: effort pr --help prints the usage" ;; *) echo "FAIL: effort pr --help: $h"; fail=1 ;; esac
|
|
62
|
+
t "--help made no forge call" "$(grep -c . "$GH_LOG")" "0"
|
|
63
|
+
|
|
64
|
+
# ── effort close with one unfinished sub ─────────────────────────────────────────────────────────
|
|
65
|
+
( cd "$tmp" && git init -q --bare remote.git )
|
|
66
|
+
( cd "$tmp" && git clone -q remote.git work 2>/dev/null \
|
|
67
|
+
&& cd work && git -c user.email=t@t -c user.name=t commit -q --allow-empty -m init \
|
|
68
|
+
&& git push -q origin HEAD:main )
|
|
69
|
+
cd "$tmp/work" || exit 1
|
|
70
|
+
effort_start 66 demo >/dev/null 2>&1
|
|
71
|
+
cd "$tmp/work/.claude/worktrees/effort+66-demo" || { echo "FAIL: no effort worktree"; exit 1; }
|
|
72
|
+
c() { git -c user.email=t@t -c user.name=t commit -q --allow-empty -m "$1"; }
|
|
73
|
+
c "$(printf 'feat: second step [E66.2]\n\nCloses #602')"
|
|
74
|
+
c "feat: third step [E66.3]"
|
|
75
|
+
c "docs: mention #604 is follow-up work (#602)" # names #604, but its last #ref is #602
|
|
76
|
+
|
|
77
|
+
: > "$GH_LOG"
|
|
78
|
+
out="$(effort_close 66 2>&1)"; rc=$?
|
|
79
|
+
cd "$tmp/work" || exit 1
|
|
80
|
+
t "close succeeds with an open sub (rc 0)" "$rc" "0"
|
|
81
|
+
tc "$GH_LOG" '^PUT repos/o/r/pulls/[0-9]+/merge ' "close squash-merges the effort PR"
|
|
82
|
+
tc "$GH_LOG" '^PATCH repos/o/r/issues/66 \{"state":"closed","state_reason":"completed"\}$' "close closes the parent"
|
|
83
|
+
tc "$GH_LOG" '^PATCH repos/o/r/issues/602 \{"state":"closed","state_reason":"completed"\}$' "close closes the sub a commit closes"
|
|
84
|
+
tc "$GH_LOG" '^PATCH repos/o/r/issues/603 \{"state":"closed","state_reason":"completed"\}$' "close closes the sub a step tag delivers"
|
|
85
|
+
t "close does not re-close the already-closed sub" "$(grep -c '^PATCH repos/o/r/issues/601 ' "$GH_LOG")" "0"
|
|
86
|
+
t "close leaves the unfinished sub open (no write to #604)" "$(grep -cE '^(PATCH|POST|PUT|DELETE) repos/o/r/issues/604' "$GH_LOG")" "0"
|
|
87
|
+
t "close detaches nothing (no DELETE of any kind)" "$(grep -c '^DELETE ' "$GH_LOG")" "0"
|
|
88
|
+
tc "$GH_LOG" '^POST repos/o/r/issues/66/comments .*Finished sub-issues: #601, #602, #603' "the close comment lists the finished subs"
|
|
89
|
+
tc "$GH_LOG" '^POST repos/o/r/issues/66/comments .*Left open, still linked.*- #604 \[E66\.4\] release later' "the close comment lists the open sub"
|
|
90
|
+
t "the comment is posted before the parent closes" \
|
|
91
|
+
"$(grep -nE '^POST repos/o/r/issues/66/comments |^PATCH repos/o/r/issues/66 ' "$GH_LOG" | sed -E 's/^[0-9]+:(POST|PATCH).*/\1/' | tr '\n' ' ')" "POST PATCH "
|
|
92
|
+
case "$out" in *"left open: sub #604"*) echo "ok: the output flags the open sub as it closes" ;; *) echo "FAIL: no left-open line: $out"; fail=1 ;; esac
|
|
93
|
+
case "$out" in *"closed with unfinished sub-issues still open"*"#604"*) echo "ok: the report ends with the open sub" ;; *) echo "FAIL: no closing report of the open sub: $out"; fail=1 ;; esac
|
|
94
|
+
t "no gh subcommand ran" "$(grep -c '^GH-SUBCOMMAND' "$GH_LOG")" "0"
|
|
95
|
+
|
|
96
|
+
[ "$fail" = 0 ] && echo "ALL OK (effort-close-subs)" || { echo "effort-close-subs: FAILURES"; exit 1; }
|
|
@@ -22,10 +22,12 @@ lib_ln="$(printf '%s\n' "$blk" | grep -n 'source "\$LIB/effort\.sh"' | sed -n 1p
|
|
|
22
22
|
t "effort) loads the project config" "$([ -n "$cfg_ln" ] && echo yes)" "yes"
|
|
23
23
|
t "config load precedes the effort libs" "$([ -n "$cfg_ln" ] && [ -n "$lib_ln" ] && [ "$cfg_ln" -lt "$lib_ln" ] && echo yes)" "yes"
|
|
24
24
|
|
|
25
|
-
# #243: every effort subcommand the usage
|
|
25
|
+
# #243: every effort subcommand the usage advertises must actually dispatch, `chain` included
|
|
26
26
|
# — a docs/code drift guard (a subcommand documented but not wired falls through to the usage line).
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
# The usage lives in the verb table (#555): one `cckit effort <sub>` line per subcommand.
|
|
28
|
+
usage_subs="$(awk -F'\t' '$1 == "effort" && $2 == "verb" { print $10 }' "$(dirname "$BIN")/../scripts/lib/verbs.tsv" \
|
|
29
|
+
| sed 's/\\n/\n/g' | awk '$1 == "cckit" && $2 == "effort" && !seen[$3]++ { printf "%s%s", sep, $3; sep = " " }')"
|
|
30
|
+
t "the verb table's usage lists the effort subcommands" "$usage_subs" "new sub retitle chain start pr close plan sprint review"
|
|
29
31
|
for s in $usage_subs; do
|
|
30
32
|
t "effort) dispatches '$s'" \
|
|
31
33
|
"$(printf '%s\n' "$blk" | grep -cE "^ ${s}\)" | tr -d ' ')" "1"
|
|
@@ -57,27 +57,22 @@ t "no branch + no window sums to zero" "$(_em_token_sum '' 0 0)" "0 0 0
|
|
|
57
57
|
|
|
58
58
|
# ── #381: helpers resolve from the lib dir, not the caller's — under bash AND zsh ─────────────────
|
|
59
59
|
# Inside a zsh FUNCTION `BASH_SOURCE` is unset and `$0` is the function name, so a per-call
|
|
60
|
-
# `dirname "${BASH_SOURCE[0]:-$0}"` pointed at the caller's directory
|
|
61
|
-
# found
|
|
62
|
-
#
|
|
60
|
+
# `dirname "${BASH_SOURCE[0]:-$0}"` pointed at the caller's directory and kit-local.sh was never
|
|
61
|
+
# found. Run from a dir OUTSIDE the repo, with no config, so only the lib-dir lookup can find it.
|
|
62
|
+
# #561: the lib no longer pushes metrics anywhere, so loading it defines no sync.
|
|
63
63
|
outside="$tmp/outside"; mkdir -p "$outside"
|
|
64
|
-
_helpers_probe() { # _helpers_probe <shell> [flag] — prints
|
|
64
|
+
_helpers_probe() { # _helpers_probe <shell> [flag] — prints SYNC-* and LOCAL-* markers
|
|
65
65
|
( cd "$outside" && env -u KIT_CONFIG LIB="$LIB" "$@" -c '
|
|
66
66
|
source "$LIB/effort-metrics.sh"
|
|
67
|
-
sync_effort_metrics
|
|
68
|
-
if declare -f engine_enabled >/dev/null 2>&1; then echo DEFINED; else echo UNDEFINED; fi
|
|
67
|
+
if declare -f sync_effort_metrics >/dev/null 2>&1; then echo SYNC-DEFINED; else echo SYNC-UNDEFINED; fi
|
|
69
68
|
_em_judge_call s u >/dev/null 2>&1
|
|
70
69
|
if declare -f kit_local_chat >/dev/null 2>&1; then echo LOCAL-DEFINED; else echo LOCAL-UNDEFINED; fi' 2>&1 )
|
|
71
70
|
}
|
|
72
71
|
_helpers_case() { # _helpers_case <label> <shell> [flag]
|
|
73
72
|
local label="$1" out; shift
|
|
74
73
|
out="$(CCKIT_MODEL_URL='' KIT_LOCAL_ENABLED=false _helpers_probe "$@")"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
case "$out" in *"engine off"*) t "$label: sync reaches the engine-off branch" "off" "off" ;;
|
|
78
|
-
*) t "$label: sync reaches the engine-off branch" "$out" "off" ;; esac
|
|
79
|
-
t "$label: engine_enabled is defined after the sync" "$(printf '%s\n' "$out" | grep -cx 'DEFINED')" "1"
|
|
80
|
-
t "$label: judge fallback finds kit-local.sh" "$(printf '%s\n' "$out" | grep -cx 'LOCAL-DEFINED')" "1"
|
|
74
|
+
t "$label: no metrics sync is defined" "$(printf '%s\n' "$out" | grep -cx 'SYNC-UNDEFINED')" "1"
|
|
75
|
+
t "$label: judge fallback finds kit-local.sh" "$(printf '%s\n' "$out" | grep -cx 'LOCAL-DEFINED')" "1"
|
|
81
76
|
}
|
|
82
77
|
_helpers_case bash bash
|
|
83
78
|
if command -v zsh >/dev/null 2>&1; then _helpers_case zsh zsh --no-rcs
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# effort-metrics.sh — local-first effort telemetry capture (#796).
|
|
3
3
|
#
|
|
4
|
-
# Writes ONE record per effort to <git-common-dir>/effort-metrics/records.jsonl.
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# The record shape below IS that schema.
|
|
4
|
+
# Writes ONE record per effort to <git-common-dir>/effort-metrics/records.jsonl. The file is the
|
|
5
|
+
# whole store: nothing pushes it anywhere (the engine sync was retired in #561). `synced_to_graph`
|
|
6
|
+
# stays in the record shape so older rows and newer rows read the same; nothing sets it true.
|
|
8
7
|
#
|
|
9
8
|
# record_effort_start <num> — stamp start epoch + write the pre-build estimate (#808).
|
|
10
9
|
# Called by effort_start when it creates the branch (#453).
|
|
@@ -35,10 +34,16 @@
|
|
|
35
34
|
# This file's own directory, resolved ONCE at load time (#381) — the only point where both shells
|
|
36
35
|
# agree. `BASH_SOURCE` is bash-only; inside a zsh *function* it is unset and `$0` is the function
|
|
37
36
|
# name, so a per-call `dirname "${BASH_SOURCE[0]:-$0}"` resolved to the CALLER's directory:
|
|
38
|
-
#
|
|
37
|
+
# kit-local.sh was never found and the judge's local fallback was skipped without saying why. At
|
|
39
38
|
# FILE scope zsh sets `$0` to the sourced file's path, so one expansion covers both shells. Same
|
|
40
39
|
# resolution as kit-gc.sh's `_KIT_GC_LIB_DIR`, whose comment explains why zsh prompt expansion
|
|
41
40
|
# (`${(%):-%x}`) is avoided and why `cd`'s stdout is discarded.
|
|
41
|
+
# The forge port (E537): every GitHub call goes through forge_* / gh_rest_* (scripts/lib/gh-rest.sh).
|
|
42
|
+
if ! command -v gh_rest_issue_json >/dev/null 2>&1; then
|
|
43
|
+
# shellcheck source=/dev/null
|
|
44
|
+
. "$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)/gh-rest.sh"
|
|
45
|
+
fi
|
|
46
|
+
|
|
42
47
|
_EM_LIB_DIR="$(CDPATH='' cd -- "$(dirname -- "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 && pwd)"
|
|
43
48
|
|
|
44
49
|
# The GitHub transport switch (#396): rest mode routes the gh calls below through gh-rest.sh.
|
|
@@ -82,7 +87,7 @@ estimate_effort() {
|
|
|
82
87
|
repo="${EFFORT_REPO:-${KIT_REPO:-}}"
|
|
83
88
|
if cckit_gh_rest; then subs="$(gh_rest_sub_issue_numbers "$repo" "$num" 2>/dev/null | grep -c .)"
|
|
84
89
|
else
|
|
85
|
-
subs="$(
|
|
90
|
+
subs="$(forge_rest graphql -f query='query($o:String!,$r:String!,$n:Int!){repository(owner:$o,name:$r){issue(number:$n){subIssues(first:50){totalCount}}}}' \
|
|
86
91
|
-F o="${repo%/*}" -F r="${repo#*/}" -F n="$num" --jq '.data.repository.issue.subIssues.totalCount' 2>/dev/null)"
|
|
87
92
|
fi
|
|
88
93
|
[[ "$subs" =~ ^[0-9]+$ ]] || subs=1; [[ "$subs" -lt 1 ]] && subs=1
|
|
@@ -327,8 +332,8 @@ capture_effort_metrics() {
|
|
|
327
332
|
# rubric → STRICT JSON {difficulty_judge:1..5, score_judge:0..1, rationale}. Falls back to the LOCAL
|
|
328
333
|
# model (kit_local_chat) when the hosted endpoint is unreachable/empty. If NEITHER is available the
|
|
329
334
|
# fields stay null and close is NEVER blocked (logs "skipped (no model)", returns 0). Idempotent:
|
|
330
|
-
# re-running overwrites the row's *_judge fields + model_id
|
|
331
|
-
#
|
|
335
|
+
# re-running overwrites the row's *_judge fields + model_id. Requires: jq, git, curl (for the
|
|
336
|
+
# hosted path).
|
|
332
337
|
|
|
333
338
|
# Truncate budget for the diff handed to the model (keep the prompt under the context window).
|
|
334
339
|
_EM_JUDGE_MAX_CHARS="${EM_JUDGE_MAX_CHARS:-12000}"
|
|
@@ -354,10 +359,9 @@ _em_judge_diff() {
|
|
|
354
359
|
# string when gh is unavailable or the section is absent — the judge still runs on the diff alone.
|
|
355
360
|
_em_judge_goal() {
|
|
356
361
|
local num="$1" repo body
|
|
357
|
-
|
|
362
|
+
forge_available || { forge_note_none "effort close" "the effort's goal is not read; the judge reads the diff alone"; printf ''; return 0; }
|
|
358
363
|
repo="${EFFORT_REPO:-${KIT_REPO:-}}"
|
|
359
|
-
|
|
360
|
-
else body="$(gh issue view "$num" --repo "$repo" --json body --jq '.body' 2>/dev/null)" || { printf ''; return 0; }; fi
|
|
364
|
+
body="$(forge_rest "repos/$repo/issues/$num" --jq '.body // ""' 2>/dev/null)" || { printf ''; return 0; }
|
|
361
365
|
[[ -n "$body" ]] || { printf ''; return 0; }
|
|
362
366
|
# Extract the lines after "## Goal" up to the next "## " heading.
|
|
363
367
|
printf '%s\n' "$body" | awk '
|
|
@@ -504,8 +508,7 @@ ${diff}${truncated_note}"
|
|
|
504
508
|
fi
|
|
505
509
|
|
|
506
510
|
# Update the effort's row: the one with .effort==num that still has a null judge (idempotent — if
|
|
507
|
-
# all rows are already judged, re-judge the most recent one).
|
|
508
|
-
# reach the graph on the next sync.
|
|
511
|
+
# all rows are already judged, re-judge the most recent one).
|
|
509
512
|
local tmp rec; tmp="$f.judge.$$"; : > "$tmp"
|
|
510
513
|
local applied=0
|
|
511
514
|
# Line-wise so we touch exactly ONE row (jq has no cross-line "first match only" state). First
|
|
@@ -542,39 +545,7 @@ ${diff}${truncated_note}"
|
|
|
542
545
|
return 0
|
|
543
546
|
fi
|
|
544
547
|
mv "$tmp" "$f"
|
|
545
|
-
echo "[#$num] judge: difficulty_judge=$dj score_judge=$sj model=$model → records.jsonl
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
# sync_effort_metrics [num] — push unsynced records.jsonl rows into the Plan Engine graph (#832).
|
|
549
|
-
# No-op when the engine is off (engine.mode:"off" → rows stay in the local buffer). Flips
|
|
550
|
-
# synced_to_graph=true ONLY on a successful POST, so a re-run retries failures without duplicating
|
|
551
|
-
# the successes. Sources the engine adapter itself if the caller didn't. [num] is only for the log.
|
|
552
|
-
sync_effort_metrics() {
|
|
553
|
-
command -v jq >/dev/null 2>&1 || return 0
|
|
554
|
-
if ! declare -f engine_call >/dev/null 2>&1; then
|
|
555
|
-
# shellcheck source=/dev/null
|
|
556
|
-
[[ -f "$_EM_LIB_DIR/engine-adapter.sh" ]] && source "$_EM_LIB_DIR/engine-adapter.sh"
|
|
557
|
-
fi
|
|
558
|
-
declare -f engine_enabled >/dev/null 2>&1 || { echo "effort-metrics: engine adapter unavailable — buffered locally" >&2; return 0; }
|
|
559
|
-
engine_enabled || { echo "effort-metrics: engine off — metrics stay in the local buffer" >&2; return 0; }
|
|
560
|
-
local d f tmp rec n=0 fail=0
|
|
561
|
-
d="$(_em_dir)" || return 0; f="$d/records.jsonl"; [[ -f "$f" ]] || return 0
|
|
562
|
-
tmp="$f.sync.$$"; : > "$tmp"
|
|
563
|
-
while IFS= read -r rec; do
|
|
564
|
-
[[ -n "$rec" ]] || continue
|
|
565
|
-
if [[ "$(jq -r '.synced_to_graph' <<<"$rec" 2>/dev/null)" == "false" ]]; then
|
|
566
|
-
if engine_call POST /plan/effort-metrics "$rec" >/dev/null 2>&1; then
|
|
567
|
-
rec="$(jq -c '.synced_to_graph=true' <<<"$rec")"; n=$((n+1))
|
|
568
|
-
else
|
|
569
|
-
fail=$((fail+1))
|
|
570
|
-
fi
|
|
571
|
-
fi
|
|
572
|
-
printf '%s\n' "$rec" >> "$tmp"
|
|
573
|
-
done < "$f"
|
|
574
|
-
mv "$tmp" "$f"
|
|
575
|
-
local msg="effort-metrics: synced $n row(s) to the engine"
|
|
576
|
-
(( fail > 0 )) && msg="$msg ($fail failed, kept for retry)"
|
|
577
|
-
echo "$msg" >&2
|
|
548
|
+
echo "[#$num] judge: difficulty_judge=$dj score_judge=$sj model=$model → records.jsonl" >&2
|
|
578
549
|
}
|
|
579
550
|
|
|
580
551
|
# recalibrate_estimator [stamp] — recompute estimator.json from the real captured dataset
|