@williacj/rigger 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +370 -2
  3. package/package.json +56 -4
  4. package/scripts/doc-reference-check.mjs +59 -0
  5. package/scripts/gate-check.mjs +249 -0
  6. package/scripts/lib/pack-result.mjs +9 -0
  7. package/scripts/record-commit.mjs +67 -0
  8. package/src/cli/doctor.mjs +1021 -0
  9. package/src/cli/init.mjs +384 -0
  10. package/src/cli/once.mjs +489 -0
  11. package/src/cli/pause.mjs +56 -0
  12. package/src/cli/plan.mjs +106 -0
  13. package/src/cli/recording.mjs +52 -0
  14. package/src/cli/report.mjs +242 -0
  15. package/src/cli/resume.mjs +96 -0
  16. package/src/cli/rigger.mjs +12 -0
  17. package/src/cli/run.mjs +10 -0
  18. package/src/cli/setup-board.mjs +108 -0
  19. package/src/cli/verbs.mjs +82 -0
  20. package/src/cli/verdict.mjs +180 -0
  21. package/src/config/validate.mjs +960 -0
  22. package/src/execution/groups.mjs +185 -0
  23. package/src/execution/kept-output.mjs +21 -0
  24. package/src/execution/role.mjs +171 -0
  25. package/src/execution/run.mjs +490 -0
  26. package/src/execution/step.mjs +26 -0
  27. package/src/execution/workspace.mjs +866 -0
  28. package/src/observation/push.mjs +103 -0
  29. package/src/observation/report.mjs +415 -0
  30. package/src/observation/sink.mjs +271 -0
  31. package/src/package-commit.json +1 -0
  32. package/src/scheduling/admission.mjs +390 -0
  33. package/src/scheduling/clock.mjs +98 -0
  34. package/src/scheduling/lane.mjs +160 -0
  35. package/src/scheduling/loop.mjs +1738 -0
  36. package/src/scheduling/pull-order.mjs +46 -0
  37. package/src/substrate/data-ref.mjs +147 -0
  38. package/src/substrate/forge/assets.mjs +5 -0
  39. package/src/substrate/forge/graphql.mjs +258 -0
  40. package/src/substrate/forge/item-write.mjs +74 -0
  41. package/src/substrate/forge/read.mjs +998 -0
  42. package/src/substrate/forge/repository-write.mjs +152 -0
  43. package/src/substrate/forge/runners.mjs +510 -0
  44. package/src/substrate/forge/schema-write.mjs +70 -0
  45. package/src/substrate/forge/write-made.mjs +40 -0
  46. package/src/substrate/git-environment.mjs +54 -0
  47. package/src/substrate/host.mjs +23 -0
  48. package/src/substrate/launchd.mjs +23 -0
  49. package/src/substrate/process-table.sh +48 -0
  50. package/src/substrate/process.mjs +2474 -0
  51. package/src/substrate/providers/adapters.mjs +8 -0
  52. package/src/substrate/providers/claude.mjs +427 -0
  53. package/src/substrate/providers/codex.mjs +349 -0
  54. package/src/substrate/standard-error.mjs +134 -0
  55. package/src/substrate/worktrees.mjs +517 -0
  56. package/src/workflow/clock-mark.mjs +40 -0
  57. package/src/workflow/escalation.mjs +110 -0
  58. package/src/workflow/facts.mjs +92 -0
  59. package/src/workflow/first-above.mjs +17 -0
  60. package/src/workflow/form-check.mjs +88 -0
  61. package/src/workflow/gate.mjs +62 -0
  62. package/src/workflow/judges.mjs +695 -0
  63. package/src/workflow/marker.mjs +265 -0
  64. package/src/workflow/next-action.mjs +456 -0
  65. package/src/workflow/status-issue.mjs +268 -0
  66. package/src/workflow/transitions.mjs +588 -0
  67. package/templates/claude/agents/architect.md +116 -0
  68. package/templates/claude/agents/engineer.md +57 -0
  69. package/templates/claude/agents/pm.md +114 -0
  70. package/templates/claude/agents/reviewer.md +37 -0
  71. package/templates/claude/agents/spike-engineer.md +80 -0
  72. package/templates/claude/hooks/refuse-reserved-git-commands.mjs +909 -0
  73. package/templates/claude/settings.json +50 -0
  74. package/templates/claude/skills/acceptance/SKILL.md +275 -0
  75. package/templates/claude/skills/agent-style/SKILL.md +78 -0
  76. package/templates/claude/skills/code-review/SKILL.md +242 -0
  77. package/templates/claude/skills/proposal/SKILL.md +175 -0
  78. package/templates/claude/skills/spec-style/SKILL.md +112 -0
  79. package/templates/claude/skills/tdd/SKILL.md +230 -0
  80. package/templates/codex/config.toml +19 -0
  81. package/templates/doc-reference-check.md +25 -0
  82. package/templates/githooks/pre-push +24 -0
  83. package/templates/github/workflows/rigger-gate.yml +209 -0
  84. package/templates/launchd/com.williacj.rigger.plist +31 -0
  85. package/templates/rigger.config.mjs +78 -0
@@ -0,0 +1,209 @@
1
+ # ABOUTME: Rigger's gate on the forge: on each event that can change a card's verdict, runs the gate
2
+ # check from Rigger installed at the pinned commit, then posts `rigger/gate` on each head SHA it read,
3
+ # with the gate App's token minted after the check, its state taken from the check's exit status.
4
+
5
+ # The forge runs this file from the default branch for every event below, whatever a pull
6
+ # request's base, and never from its head. There is no `pull_request` trigger: that event runs the
7
+ # head's copy of this file, which the `gate` environment refuses.
8
+ name: rigger-gate
9
+
10
+ on:
11
+ pull_request_target:
12
+ types: [opened, synchronize, reopened, edited]
13
+ issue_comment:
14
+ types: [created, edited, deleted]
15
+ issues:
16
+ types: [edited, labeled, unlabeled]
17
+
18
+ # The job token reads and never writes: the status is posted with the gate App's token alone.
19
+ permissions:
20
+ contents: read
21
+ issues: read
22
+ pull-requests: read
23
+
24
+ defaults:
25
+ run:
26
+ shell: bash
27
+
28
+ env:
29
+ # The commit of Rigger the gate runs. Changing it changes the live gate.
30
+ RIGGER_COMMIT: PINNED_COMMIT
31
+ # The Node major the gate runs on: one `engines` admits, and past no end of life.
32
+ NODE_MAJOR: '24'
33
+ # The gate check, inside the package installed under the runner's temporary directory.
34
+ GATE_CHECK: rigger/node_modules/@williacj/rigger/scripts/gate-check.mjs
35
+ # The event's issue or pull request number, and whether it is a pull request's.
36
+ NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
37
+ IS_PULL: ${{ github.event.pull_request != null || github.event.issue.pull_request != null }}
38
+
39
+ jobs:
40
+ # Resolves the card the event concerns, which keys the posting job's concurrency group. It reads
41
+ # nothing the posting job rules on, so a run waiting in the group reads its facts once it starts.
42
+ card:
43
+ name: Resolve the card
44
+ runs-on: ubuntu-latest
45
+ if: github.event_name != 'issue_comment' || github.event.issue.pull_request
46
+ permissions:
47
+ contents: read
48
+ issues: read
49
+ pull-requests: read
50
+ outputs:
51
+ card: ${{ steps.card.outputs.card }}
52
+ steps:
53
+ - name: Select Node 24 from the runner tool cache
54
+ run: |
55
+ version="$(
56
+ for bin in "${RUNNER_TOOL_CACHE}"/node/24.*/x64/bin; do
57
+ [ -d "${bin}" ] || continue
58
+ version="${bin%/x64/bin}"
59
+ printf '%s\n' "${version##*/}"
60
+ done | sort -t. -k2,2n -k3,3n | tail -n 1
61
+ )"
62
+ if [ -z "${version}" ]; then
63
+ echo "::error::Node 24 is absent from the runner tool cache"
64
+ exit 1
65
+ fi
66
+ printf '%s\n' "${RUNNER_TOOL_CACHE}/node/${version}/x64/bin" >> "${GITHUB_PATH}"
67
+ - name: Check the Node version
68
+ run: |
69
+ running="$(node --version)"
70
+ echo "node ${running}; this workflow names Node ${NODE_MAJOR}"
71
+ major="${running#v}"
72
+ major="${major%%.*}"
73
+ if [ "${major}" -lt "${NODE_MAJOR}" ]; then
74
+ echo "::error::the runner's Node ${running} is below Node ${NODE_MAJOR}, which this workflow names"
75
+ exit 1
76
+ fi
77
+ - name: Install Rigger at the pinned commit
78
+ run: |
79
+ mkdir -p "${RUNNER_TEMP}/rigger"
80
+ npm install --prefix "${RUNNER_TEMP}/rigger" --ignore-scripts --no-audit --no-fund "https://codeload.github.com/williacj/rigger/tar.gz/${RIGGER_COMMIT}"
81
+ - name: Resolve the card
82
+ id: card
83
+ env:
84
+ GH_TOKEN: ${{ github.token }}
85
+ run: node "${RUNNER_TEMP}/${GATE_CHECK}" card >> "${GITHUB_OUTPUT}"
86
+
87
+ # Rules on each pull request the event concerns and posts on each head it read. One card's runs
88
+ # go one at a time. A newer run cancels one still pending in the group, whatever
89
+ # `cancel-in-progress` says, so a head can go without a status. The last run starts after the
90
+ # last event and posts last.
91
+ gate:
92
+ name: Rule and post
93
+ needs: card
94
+ runs-on: ubuntu-latest
95
+ environment: gate
96
+ permissions:
97
+ contents: read
98
+ issues: read
99
+ pull-requests: read
100
+ concurrency:
101
+ group: ${{ github.workflow }}-${{ needs.card.outputs.card }}
102
+ cancel-in-progress: false
103
+ env:
104
+ GROUP: ${{ github.workflow }}-${{ needs.card.outputs.card }}
105
+ CARD: ${{ needs.card.outputs.card }}
106
+ steps:
107
+ - name: Log the group and the start
108
+ run: echo "concurrency group ${GROUP}; started $(date -u +%Y-%m-%dT%H:%M:%SZ)"
109
+ - name: Select Node 24 from the runner tool cache
110
+ run: |
111
+ version="$(
112
+ for bin in "${RUNNER_TOOL_CACHE}"/node/24.*/x64/bin; do
113
+ [ -d "${bin}" ] || continue
114
+ version="${bin%/x64/bin}"
115
+ printf '%s\n' "${version##*/}"
116
+ done | sort -t. -k2,2n -k3,3n | tail -n 1
117
+ )"
118
+ if [ -z "${version}" ]; then
119
+ echo "::error::Node 24 is absent from the runner tool cache"
120
+ exit 1
121
+ fi
122
+ printf '%s\n' "${RUNNER_TOOL_CACHE}/node/${version}/x64/bin" >> "${GITHUB_PATH}"
123
+ - name: Check the Node version
124
+ run: |
125
+ running="$(node --version)"
126
+ echo "node ${running}; this workflow names Node ${NODE_MAJOR}"
127
+ major="${running#v}"
128
+ major="${major%%.*}"
129
+ if [ "${major}" -lt "${NODE_MAJOR}" ]; then
130
+ echo "::error::the runner's Node ${running} is below Node ${NODE_MAJOR}, which this workflow names"
131
+ exit 1
132
+ fi
133
+ - name: Install Rigger at the pinned commit
134
+ run: |
135
+ mkdir -p "${RUNNER_TEMP}/rigger"
136
+ npm install --prefix "${RUNNER_TEMP}/rigger" --ignore-scripts --no-audit --no-fund "https://codeload.github.com/williacj/rigger/tar.gz/${RIGGER_COMMIT}"
137
+ - name: Map the event to its pull requests
138
+ id: map
139
+ env:
140
+ GH_TOKEN: ${{ github.token }}
141
+ run: |
142
+ node "${RUNNER_TEMP}/${GATE_CHECK}" map > "${RUNNER_TEMP}/rigger-gate-pulls"
143
+ cat "${RUNNER_TEMP}/rigger-gate-pulls"
144
+ echo "pulls=$(tr '\n' ' ' < "${RUNNER_TEMP}/rigger-gate-pulls" | sed 's/ *$//')" >> "${GITHUB_OUTPUT}"
145
+ - name: Run the gate check on each pull request
146
+ id: gate
147
+ env:
148
+ GH_TOKEN: ${{ github.token }}
149
+ PULLS: ${{ steps.map.outputs.pulls }}
150
+ run: |
151
+ : > "${RUNNER_TEMP}/rigger-gate-results"
152
+ unread=0
153
+ for pull in ${PULLS}; do
154
+ ruled="${RUNNER_TEMP}/rigger-gate-${pull}"
155
+ status=0
156
+ node "${RUNNER_TEMP}/${GATE_CHECK}" rule "${pull}" > "${ruled}" || status=$?
157
+ cat "${ruled}"
158
+ cat "${ruled}" >> "${GITHUB_STEP_SUMMARY}"
159
+ head="$(sed -n 's/^head: //p' "${ruled}" | head -n 1)"
160
+ if [ -z "${head}" ]; then
161
+ echo "::error::pull request #${pull} could not be read, so nothing is posted for this event"
162
+ unread=1
163
+ continue
164
+ fi
165
+ reason="$(sed -n 's/^refused: //p' "${ruled}" | head -n 1)"
166
+ printf '%s\t%s\t%s\n' "${head}" "${status}" "${reason}" >> "${RUNNER_TEMP}/rigger-gate-results"
167
+ done
168
+ exit "${unread}"
169
+ - name: Mint the gate App's token
170
+ id: mint
171
+ if: success() && steps.map.outputs.pulls != ''
172
+ env:
173
+ GATE_APP_ID: ${{ vars.GATE_APP_ID }}
174
+ GATE_APP_PRIVATE_KEY: ${{ secrets.GATE_APP_PRIVATE_KEY }}
175
+ run: |
176
+ set -euo pipefail
177
+ b64() { openssl base64 -A | tr '+/' '-_' | tr -d '='; }
178
+ field() { node -e 'let s = ""; process.stdin.on("data", (d) => { s += d; }).on("end", () => { console.log(JSON.parse(s)[process.argv[1]]); })' "$1"; }
179
+ api() { curl -sSf -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' "$@"; }
180
+ now="$(date +%s)"
181
+ header="$(printf '{"alg":"RS256","typ":"JWT"}' | b64)"
182
+ claims="$(printf '{"iat":%d,"exp":%d,"iss":"%s"}' "$((now - 60))" "$((now + 540))" "${GATE_APP_ID}" | b64)"
183
+ signature="$(printf '%s.%s' "${header}" "${claims}" | openssl dgst -sha256 -sign <(printf '%s\n' "${GATE_APP_PRIVATE_KEY}") | b64)"
184
+ jwt="${header}.${claims}.${signature}"
185
+ echo "::add-mask::${jwt}"
186
+ installation="$(api -H "Authorization: Bearer ${jwt}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/installation" | field id)"
187
+ token="$(api -X POST -H "Authorization: Bearer ${jwt}" "https://api.github.com/app/installations/${installation}/access_tokens" -d "{\"repositories\":[\"${GITHUB_REPOSITORY#*/}\"],\"permissions\":{\"statuses\":\"write\"}}" | field token)"
188
+ echo "::add-mask::${token}"
189
+ echo "token=${token}" >> "${GITHUB_OUTPUT}"
190
+ - name: Post rigger/gate on each head the check read
191
+ if: success() && steps.map.outputs.pulls != ''
192
+ env:
193
+ CONTEXT: rigger/gate
194
+ TOKEN: ${{ steps.mint.outputs.token }}
195
+ run: |
196
+ set -euo pipefail
197
+ while IFS=$'\t' read -r head status reason; do
198
+ body="$(STATUS="${status}" REASON="${reason}" node -e '
199
+ const state = process.env.STATUS === "0" ? "success" : "failure";
200
+ const reason = [...process.env.REASON].slice(0, 140).join("");
201
+ const description = state === "success" ? "every judge the gate needs is sound at this head" : reason || "the gate check refused this head";
202
+ console.log(JSON.stringify({ state, context: process.env.CONTEXT, description }));
203
+ ')"
204
+ curl -sSf -X POST -H "Authorization: Bearer ${TOKEN}" -H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28' "https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${head}" -d "${body}" > /dev/null
205
+ echo "posted ${body} on ${head}"
206
+ done < "${RUNNER_TEMP}/rigger-gate-results"
207
+ - name: Log the end
208
+ if: always()
209
+ run: echo "concurrency group ${GROUP}; ended $(date -u +%Y-%m-%dT%H:%M:%SZ)"
@@ -0,0 +1,31 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!-- ABOUTME: Per-user launchd job template that relaunches Rigger after login. -->
3
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4
+ <plist version="1.0">
5
+ <dict>
6
+ <key>Label</key>
7
+ <string>com.williacj.rigger</string>
8
+ <key>ProgramArguments</key>
9
+ <array>
10
+ <string>__RIGGER__</string>
11
+ <string>run</string>
12
+ </array>
13
+ <key>WorkingDirectory</key>
14
+ <string>__REPOSITORY__</string>
15
+ <key>StartInterval</key>
16
+ <integer>__START_INTERVAL__</integer>
17
+ <key>RunAtLoad</key>
18
+ <true/>
19
+ <key>ExitTimeOut</key>
20
+ <integer>__EXIT_TIMEOUT__</integer>
21
+ <key>EnvironmentVariables</key>
22
+ <dict>
23
+ <key>PATH</key>
24
+ <string>__PATH__</string>
25
+ </dict>
26
+ <key>StandardOutPath</key>
27
+ <string>__HOME__/Library/Logs/rigger/rigger.out</string>
28
+ <key>StandardErrorPath</key>
29
+ <string>__HOME__/Library/Logs/rigger/rigger.err</string>
30
+ </dict>
31
+ </plist>
@@ -0,0 +1,78 @@
1
+ // ABOUTME: This repository's Rigger config: the board it works, the roles it dispatches, the
2
+ // kinds of work it binds, and the steps that provision a card.
3
+
4
+ // This file is L4, the consumer's own layer, so it is yours rather than the engine's and it
5
+ // carries no line budget. It declares the extension points Rigger's architecture marks as the
6
+ // consumer's, in the spelling that document's published config shape gives them, and Rigger
7
+ // refuses any declaration it does not offer.
8
+ //
9
+ // `rigger init` wrote this file, and filled `repo` in from this repository's `origin` remote. It
10
+ // left the board number as `PROJECT_NUMBER`, because a board number is GitHub's and nothing
11
+ // `init` can read names it: set it to the number your board's URL ends in, and until you do
12
+ // Rigger refuses this config rather than work a board nobody chose. Everything else arrives as
13
+ // the template had it, so the column display names, the roles and the kinds of work are starting
14
+ // points rather than answers: change them to match your board, and run `rigger doctor` to check
15
+ // what you changed.
16
+ export default {
17
+ repo: 'OWNER/REPOSITORY',
18
+ board: { project: 'PROJECT_NUMBER', columns: { ready: 'Ready', coding: 'Coding', review: 'Review', owner: 'Owner', done: 'Done' }, priority: { field: 'Priority', options: ['High', 'Normal', 'Low'] } },
19
+ concurrency: 3,
20
+ worktrees: { topic: 'rigger-{number}' },
21
+ roles: {
22
+ engineer: { agent: '.claude/agents/engineer.md', provider: 'claude', tier: 'standard' },
23
+ reviewer: { agent: '.claude/agents/reviewer.md', provider: 'claude', tier: 'high' },
24
+ pm: { agent: '.claude/agents/pm.md', provider: 'claude', tier: 'high' },
25
+ architect: { agent: '.claude/agents/architect.md', provider: 'claude', tier: 'high' },
26
+ spikeEngineer: { agent: '.claude/agents/spike-engineer.md', provider: 'claude', tier: 'high' },
27
+ },
28
+ kinds: {
29
+ // One judge. `rounds` omitted, so the default of three applies (`R-LOOP-9`).
30
+ change: {
31
+ select: { labels: ['type:change'] },
32
+ maker: 'engineer',
33
+ judges: ['reviewer'],
34
+ provisioning: ['npm-ci', 'vhs'],
35
+ },
36
+ // The panel case: three agent judges concurrently, the owner last. The architect rules on a
37
+ // proposed requirement here, which is the gate `D18` rule 5 puts before the cards are cut.
38
+ spec: {
39
+ select: { labels: ['type:spec'] },
40
+ maker: 'pm',
41
+ judges: ['reviewer', 'engineer', 'architect', 'owner'],
42
+ rounds: 2,
43
+ provisioning: ['npm-ci', 'vhs'],
44
+ },
45
+ // The architect makes every delta to `ARCHITECTURE.md` (`D18` rule 1).
46
+ structure: {
47
+ select: { labels: ['type:structure'] },
48
+ maker: 'architect',
49
+ judges: ['reviewer', 'owner'],
50
+ provisioning: ['npm-ci', 'vhs'],
51
+ },
52
+ // Decomposition: the PM cuts larger work into cards (`D18` rule 4). A kind no role makes is
53
+ // never dispatched, so the role that decomposes needs a row of its own.
54
+ intake: {
55
+ select: { labels: ['type:intake'] },
56
+ maker: 'pm',
57
+ judges: ['reviewer', 'owner'],
58
+ provisioning: ['npm-ci', 'vhs'],
59
+ },
60
+ spike: {
61
+ select: { labels: ['type:spike'] },
62
+ maker: 'spikeEngineer',
63
+ judges: ['reviewer'],
64
+ provisioning: ['npm-ci', 'vhs'],
65
+ },
66
+ },
67
+ // A card carrying this label is an epic: no kind selects it, whatever else it carries, so Rigger
68
+ // never pulls it (`R-SCHED-11`). No kind may select this label itself.
69
+ epicLabel: 'type:epic',
70
+ provisioning: {
71
+ 'npm-ci': { run: 'npm ci', required: true },
72
+ // Only cards that touch the demo tape pay for this, and it declares nothing about whether the
73
+ // work requires it, so the work does not (`R-PROV-1`).
74
+ vhs: { run: 'brew list vhs || brew install vhs', select: { labels: ['area:demo'] } },
75
+ },
76
+ escalate: { 'recorded-decision': 'owner', critical: 'owner', ambiguous: 'owner' },
77
+ telemetry: { push: false },
78
+ };