@krysoworks/kryso 0.0.0-stage → 2.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +152 -2
- package/bin/kryso +31 -0
- package/bin/ship-it-status +14 -0
- package/bin/ship-ledger +14 -0
- package/bin/ship-loop +14 -0
- package/bin/ship-pass +14 -0
- package/bin/warden +14 -0
- package/dist/answer.d.ts +38 -0
- package/dist/answer.js +48 -0
- package/dist/bytes.d.ts +5 -0
- package/dist/bytes.js +35 -0
- package/dist/cleanup.d.ts +1 -0
- package/dist/cleanup.js +629 -0
- package/dist/commands.d.ts +48 -0
- package/dist/commands.js +293 -0
- package/dist/completions.d.ts +24 -0
- package/dist/completions.js +239 -0
- package/dist/daemon.d.ts +15 -0
- package/dist/daemon.js +23 -0
- package/dist/diagnose.d.ts +47 -0
- package/dist/diagnose.js +314 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +241 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.js +17 -0
- package/dist/evidence.d.ts +39 -0
- package/dist/evidence.js +327 -0
- package/dist/home.d.ts +3 -0
- package/dist/home.js +27 -0
- package/dist/install.d.ts +59 -0
- package/dist/install.js +137 -0
- package/dist/isolate.d.ts +28 -0
- package/dist/isolate.js +402 -0
- package/dist/leftovers.d.ts +5 -0
- package/dist/leftovers.js +156 -0
- package/dist/machine.d.ts +6 -0
- package/dist/machine.js +185 -0
- package/dist/palette.d.ts +147 -0
- package/dist/palette.js +167 -0
- package/dist/plan.d.ts +1 -0
- package/dist/plan.js +133 -0
- package/dist/proc.d.ts +23 -0
- package/dist/proc.js +23 -0
- package/dist/read.d.ts +1 -0
- package/dist/read.js +297 -0
- package/dist/readiness.d.ts +5 -0
- package/dist/readiness.js +64 -0
- package/dist/remote.d.ts +6 -0
- package/dist/remote.js +85 -0
- package/dist/self-update.d.ts +1 -0
- package/dist/self-update.js +224 -0
- package/dist/semver.d.ts +7 -0
- package/dist/semver.js +42 -0
- package/dist/style.d.ts +71 -0
- package/dist/style.js +187 -0
- package/dist/update.d.ts +47 -0
- package/dist/update.js +190 -0
- package/dist/work.d.ts +25 -0
- package/dist/work.js +449 -0
- package/dist/workflows.d.ts +4 -0
- package/dist/workflows.js +73 -0
- package/docker/entrypoint.sh +44 -0
- package/docker/runner.Dockerfile +39 -0
- package/package.json +65 -4
- package/scripts/install-skills.sh +607 -0
- package/skills/code-review/SKILL.md +231 -0
- package/skills/kryso/SKILL.md +107 -0
- package/skills/kryso/golden/help.rounded.ansi +23 -0
- package/skills/kryso/golden/help.square.ansi +23 -0
- package/skills/kryso/golden/help.txt +23 -0
- package/skills/kryso/golden/table-narrow.json +11 -0
- package/skills/kryso/golden/table-narrow.rounded.ansi +4 -0
- package/skills/kryso/golden/table-narrow.square.ansi +4 -0
- package/skills/kryso/golden/table.ansi +5 -0
- package/skills/kryso/golden/table.json +11 -0
- package/skills/kryso/ledger.sh +2146 -0
- package/skills/kryso/palette.json +57 -0
- package/skills/kryso/reference/resuming.md +30 -0
- package/skills/kryso/reference/routing.md +23 -0
- package/skills/kryso/reference/stage-1-claim.md +79 -0
- package/skills/kryso/reference/stage-2-build.md +133 -0
- package/skills/kryso/reference/stage-3-prove.md +51 -0
- package/skills/kryso/reference/stage-4-pr.md +76 -0
- package/skills/kryso/reference/stage-5-reconcile.md +81 -0
- package/skills/kryso/reference/stage-6-merge-or-park.md +73 -0
- package/skills/kryso/reference/stage-7-close-out.md +62 -0
- package/skills/kryso/reference/terminal.md +7 -0
- package/skills/kryso/ship-it-status.sh +1503 -0
- package/skills/kryso/ui.py +274 -0
- package/skills/kryso/ui.sh +609 -0
- package/skills/kryso-build/SKILL.md +168 -0
- package/skills/kryso-shift/SKILL.md +167 -0
- package/skills/kryso-shift/archive.py +2784 -0
- package/skills/kryso-shift/archive_checker.py +462 -0
- package/skills/kryso-shift/archive_checker_lambda.py +155 -0
- package/skills/kryso-shift/archive_health.py +364 -0
- package/skills/kryso-shift/archive_launchd.py +140 -0
- package/skills/kryso-shift/archive_remote.py +990 -0
- package/skills/kryso-shift/archiving-checker.md +140 -0
- package/skills/kryso-shift/archiving-keep.md +115 -0
- package/skills/kryso-shift/archiving-recovery.md +112 -0
- package/skills/kryso-shift/archiving-remote.md +166 -0
- package/skills/kryso-shift/archiving.md +146 -0
- package/skills/kryso-shift/coverage.schema.json +225 -0
- package/skills/kryso-shift/deadline.sh +254 -0
- package/skills/kryso-shift/feedback.schema.json +35 -0
- package/skills/kryso-shift/feedback.sh +228 -0
- package/skills/kryso-shift/history-manifest.schema.json +331 -0
- package/skills/kryso-shift/keep-after.sh +55 -0
- package/skills/kryso-shift/measure.sh +611 -0
- package/skills/kryso-shift/merge-ready.sh +207 -0
- package/skills/kryso-shift/outcome.schema.json +16 -0
- package/skills/kryso-shift/pass-rules.md +8 -0
- package/skills/kryso-shift/profile.schema.json +42 -0
- package/skills/kryso-shift/reader.sh +692 -0
- package/skills/kryso-shift/reads.sh +151 -0
- package/skills/kryso-shift/reference/allowance.md +21 -0
- package/skills/kryso-shift/reference/driver.md +95 -0
- package/skills/kryso-shift/reference/measuring.md +67 -0
- package/skills/kryso-shift/reference/outputs.md +21 -0
- package/skills/kryso-shift/reference/pass-script.md +115 -0
- package/skills/kryso-shift/reference/reconcile-and-merge.md +55 -0
- package/skills/kryso-shift/reference/second-reader.md +9 -0
- package/skills/kryso-shift/reference/sweeps.md +83 -0
- package/skills/kryso-shift/repair.schema.json +14 -0
- package/skills/kryso-shift/report-template.html +679 -0
- package/skills/kryso-shift/report.py +389 -0
- package/skills/kryso-shift/report_fixture.py +65 -0
- package/skills/kryso-shift/reporting.md +58 -0
- package/skills/kryso-shift/result.sh +91 -0
- package/skills/kryso-shift/runner.sh +1178 -0
- package/skills/kryso-shift/ship-loop.sh +3977 -0
- package/skills/kryso-shift/ship-pass.sh +4987 -0
- package/skills/kryso-shift/steps.jq +19 -0
- package/skills/kryso-shift/workflow.mjs +830 -0
- package/skills/kryso-shift/workflows/default.json +22 -0
- package/skills/kryso-shift/workflows/ralph.json +13 -0
- package/skills/kryso-watch/SKILL.md +100 -0
- package/skills/kryso-watch/answer.schema.json +23 -0
- package/skills/kryso-watch/base-refs.sh +44 -0
- package/skills/kryso-watch/board.sh +58 -0
- package/skills/kryso-watch/reference/config.md +23 -0
- package/skills/kryso-watch/reference/outputs.md +30 -0
- package/skills/kryso-watch/reference/report.md +29 -0
- package/skills/kryso-watch/reference/scheduler.md +32 -0
- package/skills/kryso-watch/reference/settlement.md +29 -0
- package/skills/kryso-watch/reference/shift.md +44 -0
- package/skills/kryso-watch/reference/shim-limits.md +22 -0
- package/skills/kryso-watch/reference/triage.md +26 -0
- package/skills/kryso-watch/schema.jq +40 -0
- package/skills/kryso-watch/settle.schema.json +36 -0
- package/skills/kryso-watch/stage-common.sh +187 -0
- package/skills/kryso-watch/stages/report.sh +525 -0
- package/skills/kryso-watch/stages/settle.sh +722 -0
- package/skills/kryso-watch/stages/shift.sh +466 -0
- package/skills/kryso-watch/stages/triage.sh +379 -0
- package/skills/kryso-watch/tracker.sh +27 -0
- package/skills/kryso-watch/triage.schema.json +77 -0
- package/skills/kryso-watch/warden.launchd.plist +50 -0
- package/skills/kryso-watch/warden.schema.json +98 -0
- package/skills/kryso-watch/warden.sh +1004 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# merge-ready.sh: the one reading of whether a pull request's evidence makes it merge-ready, which
|
|
3
|
+
# the driver's stacked sweep and the pass script's merge both make. The sweep asks it for a
|
|
4
|
+
# dependent: may an issue that this blocker blocks start on the blocker's branch now? The merge
|
|
5
|
+
# asks it for itself: may the pass merge this PR into its base now? The two questions share
|
|
6
|
+
# every read but five, and those five differ on purpose, so they are named here as two rules over
|
|
7
|
+
# one document rather than carried as two copies that drift:
|
|
8
|
+
#
|
|
9
|
+
# read dependent merge
|
|
10
|
+
# proof head not read: /kryso's stage 3 records no the last proof is of this very head
|
|
11
|
+
# proof head, only the gate lines
|
|
12
|
+
# origin's branch not read: the PR head being the fetched, and at this head
|
|
13
|
+
# worktree's stands for it
|
|
14
|
+
# base read when the caller names one: the always read, and a merge that names
|
|
15
|
+
# driver names none, because a stacked none is refused
|
|
16
|
+
# PR targets the branch it was cut from
|
|
17
|
+
# mergeable anything but CONFLICTING: GitHub MERGEABLE: GitHub refuses the merge
|
|
18
|
+
# computes it lazily, and a dependent otherwise
|
|
19
|
+
# builds on the branch, not on the merge
|
|
20
|
+
# no checks refused, and so is a PR whose checks accepted where the reconcile stage
|
|
21
|
+
# all skipped: a dependent needs a recorded no-ci, as /kryso does
|
|
22
|
+
# passed check
|
|
23
|
+
#
|
|
24
|
+
# Every other read is the same under both, in the same order, with the same reason: the tree on
|
|
25
|
+
# its branch with nothing uncommitted outside the ledger directory, the ledger read and its gate
|
|
26
|
+
# green, the PR open from that branch at the tree's head, every check
|
|
27
|
+
# passed or skipped, none failed, cancelled or pending, and the feedback read whole by
|
|
28
|
+
# feedback.sh with nothing actionable on that head. Every read fails closed: an answer that
|
|
29
|
+
# cannot be read is a reason, never an empty set.
|
|
30
|
+
#
|
|
31
|
+
# Sourced, it defines merge_ready_read, merge_ready_judge, gh_refusal_final and gh_refusal_line
|
|
32
|
+
# and runs nothing. It needs jq, and
|
|
33
|
+
# for the read git, gh, ledger.sh's `ledger` and feedback.sh's `feedback_actionable`, sourced by
|
|
34
|
+
# the caller. Run as a command:
|
|
35
|
+
# merge-ready.sh judge the evidence document on stdin, the verdict on stdout: exit 0 when
|
|
36
|
+
# ready, 1 when not, 64 for a document it cannot judge
|
|
37
|
+
|
|
38
|
+
# gh_refusal_final <stderr file>: whether the refusal gh printed there is one a retry cannot fix:
|
|
39
|
+
# credentials GitHub rejects, a token it refuses this resource, or a pull request or repository
|
|
40
|
+
# it does not have. Any other refusal, a server error or a dropped connection among them, may
|
|
41
|
+
# answer on the next read, so a caller with a deadline reads again until it passes.
|
|
42
|
+
# gh_refusal_line <read> <exit> <stderr file>: one refusal as the ledger records it, `<read>
|
|
43
|
+
# exit=<n> at <time>: <gh's first line>`. Neither uses a variable or function of the script's,
|
|
44
|
+
# so a caller can export both to a bash of its own.
|
|
45
|
+
gh_refusal_final() {
|
|
46
|
+
grep -qiE 'gh auth login|HTTP 401|bad credentials|requires authentication|no pull requests? found|could not resolve to a (pullrequest|repository)|HTTP 404|resource not accessible' "$1" 2>/dev/null
|
|
47
|
+
}
|
|
48
|
+
gh_refusal_line() {
|
|
49
|
+
printf '%s exit=%s at %s: %s\n' "$1" "$2" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$(head -1 "$3" 2>/dev/null)"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# merge_ready_judge: the verdict on the evidence document on stdin, {ready, rule, reason, head,
|
|
53
|
+
# evidence, checks}, exit 0 when ready and 1 when not. The document is what merge_ready_read
|
|
54
|
+
# gathers: {rule, branch, base, pr, tree: {on, dirty, head}, ledger: {proof_known, gate, proof, ci},
|
|
55
|
+
# origin: {fetched, head}, view: <the PR's state, head and base>, checks: <list> | {unreadable},
|
|
56
|
+
# feedback: {actionable, authors, head} | {unreadable}, logs: {checks, feedback} | null}, where a
|
|
57
|
+
# null is a read that found nothing. Exit 64, with the reason on stderr, for a document that is
|
|
58
|
+
# not one or a rule it does not know.
|
|
59
|
+
merge_ready_judge() {
|
|
60
|
+
local doc rule verdict
|
|
61
|
+
IFS= read -r -d '' doc || true
|
|
62
|
+
jq -e 'type == "object"' <<< "$doc" >/dev/null 2>&1 \
|
|
63
|
+
|| { echo "merge-ready: judge reads one evidence document, a JSON object" >&2; return 64; }
|
|
64
|
+
rule="$(jq -r '.rule // ""' <<< "$doc")"
|
|
65
|
+
[[ "$rule" == dependent || "$rule" == merge ]] \
|
|
66
|
+
|| { echo "merge-ready: the rule is dependent or merge, got '$rule'" >&2; return 64; }
|
|
67
|
+
verdict="$(jq -c '
|
|
68
|
+
# The five reads the rules differ on, as data, so a sixth difference is a column here.
|
|
69
|
+
def rules: {
|
|
70
|
+
dependent: {proof: false, origin: false, base: "when-named", mergeable: "not-conflicting", no_checks: "refused"},
|
|
71
|
+
merge: {proof: true, origin: true, base: "required", mergeable: "mergeable", no_checks: "recorded"}
|
|
72
|
+
};
|
|
73
|
+
def short: if . == null or . == "" then "none" else .[0:12] end;
|
|
74
|
+
. as $d | rules[$d.rule] as $r | ($d.tree.head // "") as $h | $d.pr as $pr
|
|
75
|
+
| (if $d.logs != null then " (\($d.logs.checks))" else "" end) as $checks_log
|
|
76
|
+
| (if $d.logs != null then " (\($d.logs.feedback))" else "" end) as $feedback_log
|
|
77
|
+
| ($d.checks | if type == "array" then . else null end) as $checks
|
|
78
|
+
| (if $checks == null then null else [$checks[] | select(.bucket == "fail" or .bucket == "cancel") | .name] end) as $red
|
|
79
|
+
| (if $checks == null then null else [$checks[] | select(.bucket != "pass" and .bucket != "skipping" and .bucket != "fail" and .bucket != "cancel") | .name] end) as $pending
|
|
80
|
+
| (if $d.tree.on != $d.branch then "the worktree is on \($d.tree.on // "a detached HEAD"), not \($d.branch)"
|
|
81
|
+
elif $d.tree.dirty then "the worktree has uncommitted changes"
|
|
82
|
+
elif $d.ledger == null then "cannot read the worktree'"'"'s ledger"
|
|
83
|
+
elif $r.proof and ($d.ledger.proof_known // false | not) then "the ledger module is older than this read, and its document names no proof head"
|
|
84
|
+
elif $r.proof and $d.ledger.proof == null then "no gate run is recorded over any head, so nothing proves \($h | short)"
|
|
85
|
+
elif $r.proof and $d.ledger.proof.head != $h then "the gate last proved \($d.ledger.proof.head | short), not the head \($h | short)"
|
|
86
|
+
elif ($d.ledger.gate.verdict // "missing") != "green" then "the ledger'"'"'s gate is not green: \(($d.ledger.gate.reason // "") | if . == "" then "no verdict" else . end)"
|
|
87
|
+
elif $r.origin and ($d.origin.fetched // false | not) then "cannot fetch \($d.branch) from origin"
|
|
88
|
+
elif $r.origin and $d.origin.head != $h then "origin'"'"'s \($d.branch) is at \($d.origin.head | short), not the proved head \($h | short)"
|
|
89
|
+
elif $d.view == null then "cannot read \($pr)"
|
|
90
|
+
elif $d.view.state != "OPEN" then "\($pr) is \($d.view.state // "unreadable"), not open"
|
|
91
|
+
elif $d.view.headRefName != $d.branch then "\($pr) is from \($d.view.headRefName // "an unknown branch"), not \($d.branch)"
|
|
92
|
+
elif $r.base == "required" and ($d.base // "") == "" then "the merge names no base to read \($pr) against"
|
|
93
|
+
elif ($d.base // "") != "" and $d.view.baseRefName != $d.base then "\($pr) targets \($d.view.baseRefName // "an unknown base"), not \($d.base)"
|
|
94
|
+
elif $d.view.headRefOid != $h then "PR head \($d.view.headRefOid | short) is not the worktree'"'"'s \($h | short), so someone else pushed"
|
|
95
|
+
elif ($r.mergeable == "mergeable" and $d.view.mergeable != "MERGEABLE")
|
|
96
|
+
or ($r.mergeable == "not-conflicting" and $d.view.mergeable == "CONFLICTING") then "\($pr) is not mergeable: \($d.view.mergeable // "unknown")"
|
|
97
|
+
elif $checks == null then "cannot read the checks on \($pr): \($d.checks.unreadable // "not a list")"
|
|
98
|
+
elif ($red | length) > 0 then "checks red: \($red | join(", "))\($checks_log)"
|
|
99
|
+
elif ($pending | length) > 0 then "checks pending: \($pending | join(", "))\($checks_log)"
|
|
100
|
+
elif $r.no_checks == "refused" and ($checks | length) == 0 then "no CI checks on \($pr)"
|
|
101
|
+
elif $r.no_checks == "refused" and ([$checks[] | select(.bucket == "pass")] | length) == 0 then "no check on \($pr) passed"
|
|
102
|
+
elif $r.no_checks == "recorded" and ($checks | length) == 0 and ($d.ledger.ci.state // "") != "none"
|
|
103
|
+
then "no checks on \($pr), where the reconcile stage read \($d.ledger.ci.state // "nothing")"
|
|
104
|
+
elif ($d.feedback | type) != "object" or ($d.feedback | has("unreadable")) then "cannot read the feedback on \($pr): \($d.feedback.unreadable? // "no answer")"
|
|
105
|
+
elif ($d.feedback.actionable | length) > 0 then "actionable feedback on \($pr): \($d.feedback.actionable | join(" ")) by \($d.feedback.authors | join(", "))\($feedback_log)"
|
|
106
|
+
elif $d.feedback.head != $h then "the feedback stands on \($d.feedback.head | short), not the head \($h | short)"
|
|
107
|
+
else null end) as $reason
|
|
108
|
+
| {ready: ($reason == null), rule: $d.rule, reason: $reason, head: (if $h == "" then null else $h end),
|
|
109
|
+
evidence: (if $reason != null then null else
|
|
110
|
+
"\($d.ledger.gate.evidence); checks \(if ($checks | length) == 0 then "none (no-ci)" else "green \($checks | length)" end); feedback none actionable" end),
|
|
111
|
+
checks: ($checks // [] | length)}' <<< "$doc")" \
|
|
112
|
+
|| { echo "merge-ready: cannot judge the evidence document" >&2; return 64; }
|
|
113
|
+
printf '%s\n' "$verdict"
|
|
114
|
+
[[ "$(jq -r .ready <<< "$verdict")" == true ]]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# merge_ready_read <rule> <worktree> <branch> <pr> <owner/repo> [<base>] [<log dir>] [<read
|
|
118
|
+
# wait>]: every read the rule stands on, made now, judged. Sets MR_VERDICT to the verdict,
|
|
119
|
+
# MR_REASON to why it is not ready or empty, MR_HEAD to the head it stands on, MR_EVIDENCE to
|
|
120
|
+
# what was read, MR_CHECKS to how many checks there were and MR_REFUSALS to one line for each
|
|
121
|
+
# checks read gh refused, and returns 0 when ready, 1 when not. The PR is a number or its URL.
|
|
122
|
+
# With a log directory, the checks and the feedback as read are kept there as merge-checks.json
|
|
123
|
+
# and merge-feedback.json, and the reasons name them. With a read wait in seconds, a refused
|
|
124
|
+
# checks read is made again until that many seconds pass, as the reconcile poll does, unless
|
|
125
|
+
# gh_refusal_final names it. The driver's sweep gives none, because its next sweep reads again.
|
|
126
|
+
merge_ready_read() {
|
|
127
|
+
local rule="$1" wt="$2" branch="$3" pr="$4" nwo="$5" base="${6:-}" logdir="${7:-}" read_wait="${8:-0}"
|
|
128
|
+
local head on dirty=false doc ledger_doc=null origin=null view checks err code number fb feedback logs=null fetched deadline remaining
|
|
129
|
+
MR_VERDICT=""; MR_REASON=""; MR_HEAD=""; MR_EVIDENCE=""; MR_CHECKS=0; MR_REFUSALS=""
|
|
130
|
+
head="$(git -C "$wt" rev-parse -q --verify HEAD 2>/dev/null)" || head=""
|
|
131
|
+
on="$(git -C "$wt" symbolic-ref -q --short HEAD 2>/dev/null)" || on=""
|
|
132
|
+
# The ledger directory is the run's record, not the change, whether or not the repository
|
|
133
|
+
# excludes it, so it does not count as uncommitted work. Which directory that is, is the module's
|
|
134
|
+
# to say: configuration beside .kryso/pass/ is the change, and counts.
|
|
135
|
+
local ld="$wt/.kryso/pass" rel
|
|
136
|
+
! declare -F _ledger_d >/dev/null || _ledger_d "$wt" ld
|
|
137
|
+
rel="${ld#"$wt"/}"
|
|
138
|
+
[[ -z "$(git -C "$wt" status --porcelain 2>/dev/null | grep -vF -e "?? $rel/" -e "?? \"$rel/" -e '?? .ship-it/' -e '?? .ship-it')" ]] || dirty=true
|
|
139
|
+
# A module whose document predates the proof head is told apart from a ledger with no proof.
|
|
140
|
+
if declare -F ledger >/dev/null && doc="$(ledger read "$wt" 2>/dev/null)"; then
|
|
141
|
+
ledger_doc="$(jq -c '{proof_known: (has("proof") and has("ci")), gate, proof, ci}' <<< "$doc" 2>/dev/null)" || ledger_doc=null
|
|
142
|
+
[[ -n "$ledger_doc" ]] || ledger_doc=null
|
|
143
|
+
fi
|
|
144
|
+
if [[ "$rule" == merge ]]; then
|
|
145
|
+
fetched=false
|
|
146
|
+
! git -C "$wt" fetch -q origin "$branch" >/dev/null 2>&1 || fetched=true
|
|
147
|
+
origin="$(jq -cn --argjson f "$fetched" --arg h "$(git -C "$wt" rev-parse -q --verify "origin/$branch^{commit}" 2>/dev/null)" \
|
|
148
|
+
'{fetched: $f, head: (if $f and $h != "" then $h else null end)}')"
|
|
149
|
+
fi
|
|
150
|
+
view="$(gh pr view "$pr" --json state,headRefName,headRefOid,baseRefName,mergeable 2>/dev/null)" \
|
|
151
|
+
&& jq -e 'type == "object" and (.state | type) == "string"' <<< "$view" >/dev/null 2>&1 || view=null
|
|
152
|
+
# gh pr checks exits non-zero for red and pending checks too, with the list on stdout. Only
|
|
153
|
+
# an answer with no list is a failure, and of those only "no checks reported" is an empty set.
|
|
154
|
+
err="$(mktemp)" || err=/dev/null
|
|
155
|
+
deadline=$(( $(date -u +%s) + read_wait ))
|
|
156
|
+
while :; do
|
|
157
|
+
checks="$(gh pr checks "$pr" --json bucket,name,link,state,workflow 2>"$err")"; code=$?
|
|
158
|
+
[[ "$code" -ne 0 && ! "$checks" =~ ^\[ ]] || break
|
|
159
|
+
if grep -qi 'no checks reported' "$err" 2>/dev/null; then checks="[]"; break; fi
|
|
160
|
+
MR_REFUSALS+="$(gh_refusal_line "gh pr checks" "$code" "$err")"$'\n'
|
|
161
|
+
remaining=$(( deadline - $(date -u +%s) ))
|
|
162
|
+
if gh_refusal_final "$err" || [[ "$remaining" -le 0 ]]; then
|
|
163
|
+
checks="$(jq -cn --arg w "$(head -1 "$err" 2>/dev/null)" --arg c "$code" '{unreadable: (if $w == "" then "gh pr checks exit=\($c)" else $w end)}')"
|
|
164
|
+
break
|
|
165
|
+
fi
|
|
166
|
+
sleep "$(( remaining < 30 ? remaining : 30 ))"
|
|
167
|
+
done
|
|
168
|
+
[[ "$err" == /dev/null ]] || rm -f "$err"
|
|
169
|
+
[[ -n "$checks" ]] || checks='{"unreadable":"gh pr checks answered nothing"}'
|
|
170
|
+
jq -e 'type == "array" or (type == "object" and has("unreadable"))' <<< "$checks" >/dev/null 2>&1 || checks='{"unreadable":"not a list"}'
|
|
171
|
+
number="${pr##*/}"
|
|
172
|
+
if [[ ! "$number" =~ ^[0-9]+$ ]]; then fb="unreadable: '$pr' names no pull request number"; code=1
|
|
173
|
+
elif [[ -z "$nwo" ]]; then fb="unreadable: cannot read this repo's owner and name"; code=1
|
|
174
|
+
elif ! declare -F feedback_actionable >/dev/null; then fb="unreadable: feedback.sh is not sourced"; code=1
|
|
175
|
+
else fb="$(feedback_actionable "$nwo" "$number")"; code=$?; fi
|
|
176
|
+
if [[ "$code" -ne 0 ]]; then
|
|
177
|
+
feedback="$(jq -cn --arg w "${fb#unreadable: }" '{unreadable: (if $w == "" then "no answer" else $w end)}')"
|
|
178
|
+
elif ! feedback="$(jq -ce '{actionable, authors, head} | select((.actionable | type) == "array" and (.authors | type) == "array")' <<< "$fb" 2>/dev/null)"; then
|
|
179
|
+
feedback='{"unreadable":"the feedback read answered with the wrong shape"}'
|
|
180
|
+
fi
|
|
181
|
+
if [[ -n "$logdir" ]]; then
|
|
182
|
+
logs='{"checks":"logs/merge-checks.json","feedback":"logs/merge-feedback.json"}'
|
|
183
|
+
! jq -e 'type == "array"' <<< "$checks" >/dev/null 2>&1 || printf '%s\n' "$checks" > "$logdir/merge-checks.json"
|
|
184
|
+
printf '%s\n' "$fb" > "$logdir/merge-feedback.json"
|
|
185
|
+
fi
|
|
186
|
+
MR_VERDICT="$(jq -cn --arg rule "$rule" --arg branch "$branch" --arg base "$base" --arg pr "$pr" \
|
|
187
|
+
--arg on "$on" --argjson dirty "$dirty" --arg head "$head" --argjson ledger "$ledger_doc" --argjson origin "$origin" \
|
|
188
|
+
--argjson view "$view" --argjson checks "$checks" --argjson feedback "$feedback" --argjson logs "$logs" \
|
|
189
|
+
'{rule: $rule, branch: $branch, base: (if $base == "" then null else $base end), pr: $pr,
|
|
190
|
+
tree: {on: (if $on == "" then null else $on end), dirty: $dirty, head: (if $head == "" then null else $head end)},
|
|
191
|
+
ledger: $ledger, origin: $origin, view: $view, checks: $checks, feedback: $feedback, logs: $logs}' | merge_ready_judge)"
|
|
192
|
+
code=$?
|
|
193
|
+
[[ "$code" -le 1 && -n "$MR_VERDICT" ]] || { MR_REASON="cannot judge the evidence on $pr"; return 1; }
|
|
194
|
+
MR_REASON="$(jq -r '.reason // ""' <<< "$MR_VERDICT")"
|
|
195
|
+
MR_HEAD="$(jq -r '.head // ""' <<< "$MR_VERDICT")"
|
|
196
|
+
MR_EVIDENCE="$(jq -r '.evidence // ""' <<< "$MR_VERDICT")"
|
|
197
|
+
MR_CHECKS="$(jq -r '.checks' <<< "$MR_VERDICT")"
|
|
198
|
+
return "$code"
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
|
|
202
|
+
set -uo pipefail
|
|
203
|
+
case "${1:-}" in
|
|
204
|
+
judge) merge_ready_judge; exit $? ;;
|
|
205
|
+
*) echo "usage: merge-ready.sh judge < evidence.json" >&2; exit 64 ;;
|
|
206
|
+
esac
|
|
207
|
+
fi
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"outcome": {
|
|
5
|
+
"type": "string",
|
|
6
|
+
"enum": ["shipped", "parked", "nothing-to-take", "failed"],
|
|
7
|
+
"description": "How the run ended."
|
|
8
|
+
},
|
|
9
|
+
"issue": { "type": "string", "description": "The issue number worked, or \"none\"." },
|
|
10
|
+
"branch": { "type": "string", "description": "The branch the work is on, or \"none\"." },
|
|
11
|
+
"pr": { "type": "string", "description": "The pull request URL, or \"none\"." },
|
|
12
|
+
"reason": { "type": "string", "description": "One paragraph: what landed, or what stopped it and where the evidence is." }
|
|
13
|
+
},
|
|
14
|
+
"required": ["outcome", "issue", "branch", "pr", "reason"],
|
|
15
|
+
"additionalProperties": false
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Rules for every pass context
|
|
2
|
+
|
|
3
|
+
This pass runs unattended on a machine a person also uses. These rules hold in every context of it, whatever a skill or a brief says.
|
|
4
|
+
|
|
5
|
+
- Never stop, restart or bind a dev server or port that this pass did not start. Never use a broad `pkill` or `kill` on `node`, `next dev` or `next-server`. A dev server the pass needs runs on a high port it chooses, passed explicitly, and the pass checks that the server bound that port.
|
|
6
|
+
- Check an environment variable by name (`printenv NAME`), never with bare `env`, `printenv` or `set`, which print every secret the shell holds.
|
|
7
|
+
- Never set `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_CUSTOM_HEADERS` or `OPENAI_BASE_URL`, and never edit the host's user settings to point at a gateway.
|
|
8
|
+
- A subagent does not inherit this system prompt. When you dispatch one that can run commands, put these rules in its prompt.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://github.com/krysoworks/kryso/skills/kryso-shift/profile.schema.json",
|
|
4
|
+
"title": "ship-loop execution profiles",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["profiles"],
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"profiles": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"propertyNames": { "minLength": 1 },
|
|
12
|
+
"additionalProperties": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"required": ["host"],
|
|
15
|
+
"additionalProperties": false,
|
|
16
|
+
"properties": {
|
|
17
|
+
"host": { "enum": ["claude", "codex"] },
|
|
18
|
+
"model": { "type": "string", "minLength": 1 },
|
|
19
|
+
"effort": { "type": "string" }
|
|
20
|
+
},
|
|
21
|
+
"allOf": [
|
|
22
|
+
{
|
|
23
|
+
"if": { "properties": { "host": { "const": "claude" } } },
|
|
24
|
+
"then": {
|
|
25
|
+
"properties": {
|
|
26
|
+
"effort": { "enum": ["low", "medium", "high", "xhigh", "max"] }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"if": { "properties": { "host": { "const": "codex" } } },
|
|
32
|
+
"then": {
|
|
33
|
+
"properties": {
|
|
34
|
+
"effort": { "enum": ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"] }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|