wachiman 1.13.0 → 1.14.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/README.md +1 -1
- package/bin/wachiman.js +1 -1
- package/package.json +2 -3
- package/skills/wachiman-review/SKILL.md +2 -2
- package/src/cli.ts +35 -16
- package/src/config.ts +83 -35
- package/src/connectors/local-git.ts +1 -1
- package/src/cost.ts +28 -1
- package/src/engine.ts +382 -38
- package/src/history/store.ts +5 -5
- package/src/init/options.ts +1 -1
- package/src/ledger.ts +306 -0
- package/src/local.ts +4 -4
- package/src/providers/claude-code.ts +1 -1
- package/src/providers/codex.ts +5 -5
- package/src/providers/index.ts +1 -1
- package/src/providers/types.ts +3 -3
- package/src/sinks/common.ts +3 -3
- package/src/status/command.ts +1 -1
- package/templates/caller-workflow.yml +44 -47
- package/templates/wachiman-review-caller.yml +5 -0
|
@@ -9,13 +9,13 @@ name: Wachiman review
|
|
|
9
9
|
# gate. What to look for beyond the defaults is in `.github/wachiman.md`.
|
|
10
10
|
#
|
|
11
11
|
# The "copy the files" workflow template. Copy it with the `src/` folder of niway-dev/wachiman
|
|
12
|
-
# (as `scripts/
|
|
12
|
+
# (as `scripts/wachiman/`, see docs/setup-copy.md), record the decision in the repository's ADRs, and edit the
|
|
13
13
|
# trust paragraph below to say who can push. It runs narrowly:
|
|
14
14
|
# - `review`: when a pull request opens ready for review or leaves draft, and on every later
|
|
15
15
|
# push (`synchronize`), which reviews only the commits that are new since the last review.
|
|
16
16
|
# A rebase with no change in content posts a one-line marker and calls no model. Each push
|
|
17
|
-
# can spend up to
|
|
18
|
-
# together up to
|
|
17
|
+
# can spend up to WACHIMAN_BUDGET_USD, and all automatic runs on one pull request
|
|
18
|
+
# together up to WACHIMAN_AUTO_BUDGET_USD (`/wachiman review` is not limited by it); to
|
|
19
19
|
# review only on open and on `/wachiman review`, remove `synchronize` from the `pull_request`
|
|
20
20
|
# types below.
|
|
21
21
|
# - `threads`: when the repository owner replies in a review thread (a
|
|
@@ -35,10 +35,10 @@ name: Wachiman review
|
|
|
35
35
|
# own copy, and the checkout is the process's working directory). The reusable workflow
|
|
36
36
|
# (templates/wachiman-review-caller.yml) checks them out as siblings and is preferred; to move
|
|
37
37
|
# an existing copy there, see docs/setup-copy.md. This copy
|
|
38
|
-
# still runs `bun --no-env-file --config=scripts/
|
|
38
|
+
# still runs `bun --no-env-file --config=scripts/wachiman/bunfig.toml ... --repo-dir .`, so
|
|
39
39
|
# Bun reads no `bunfig.toml` or `.env` from the head; copy `bunfig.toml` next to `cli.ts`.
|
|
40
40
|
#
|
|
41
|
-
# Before the agent is called, `scripts/
|
|
41
|
+
# Before the agent is called, `scripts/wachiman/cli.ts` drops lockfiles, build output and
|
|
42
42
|
# generated files, then packs the rest into batches of about 1,000 changed lines, riskiest
|
|
43
43
|
# first, one agent call each with its diff inside the prompt. A batch that leaves files
|
|
44
44
|
# unaccounted for is re-run once with only those files. A pull request whose estimate is above
|
|
@@ -50,7 +50,7 @@ name: Wachiman review
|
|
|
50
50
|
# Comments come from `github-actions[bot]` through the workflow token, so no GitHub
|
|
51
51
|
# App needs to be installed.
|
|
52
52
|
#
|
|
53
|
-
# Both jobs run `scripts/
|
|
53
|
+
# Both jobs run `scripts/wachiman/cli.ts`: the agent only reads (files, the PR, its diff),
|
|
54
54
|
# and the CLI posts the review, within the budgets below. That is enough
|
|
55
55
|
# here because only the owner pushes (EDIT THIS: say who can open pull requests in this
|
|
56
56
|
# repository), so everything the agent reads is trusted. A public repository needs more
|
|
@@ -95,39 +95,39 @@ env:
|
|
|
95
95
|
# batches are listed as not reviewed.
|
|
96
96
|
# A pull request edits these for its own `review` run, which the trust assumption above
|
|
97
97
|
# accepts.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
WACHIMAN_BATCH_LINES: 1000
|
|
99
|
+
WACHIMAN_BATCH_BUDGET_USD: 0.75
|
|
100
|
+
WACHIMAN_BUDGET_USD: 3
|
|
101
101
|
# The most all automatic runs on one pull request (first review, push reviews, thread replies)
|
|
102
102
|
# may spend together; the engine sums it from its own signed review footers. `/wachiman review`
|
|
103
103
|
# is not limited by it. A thread-reply run has its own cap, inside this one.
|
|
104
|
-
|
|
104
|
+
WACHIMAN_AUTO_BUDGET_USD: 2
|
|
105
105
|
# A review whose estimate (from the diff size, before any model call) is above this is skipped
|
|
106
106
|
# with one comment. It is never below what the run may spend, so raising the budgets lifts it.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
WACHIMAN_SIZE_GATE_USD: 6
|
|
108
|
+
WACHIMAN_THREADS_BUDGET_USD: 0.25
|
|
109
|
+
WACHIMAN_ANSWER_BUDGET_USD: 1
|
|
110
110
|
# Who may ask a question by comment: `operator` (only the operator) or `write` (also a collaborator
|
|
111
111
|
# with admin, maintain or write permission). Set it to `write` together with the literal
|
|
112
112
|
# `'operator' == 'write'` in the `threads` and `on-demand` `if:` below (EDIT THIS), since a job
|
|
113
113
|
# `if:` cannot read this variable.
|
|
114
|
-
|
|
114
|
+
WACHIMAN_ASKERS: operator
|
|
115
115
|
# The most all questions from people other than the operator may spend on one pull request.
|
|
116
|
-
|
|
116
|
+
WACHIMAN_ASK_CEILING_USD: 3
|
|
117
117
|
# The login allowed to command the tool (EDIT THIS). The `on-demand` job `if:` checks the same
|
|
118
118
|
# login, and the CLI checks it again against the comment's author.
|
|
119
|
-
|
|
119
|
+
WACHIMAN_OPERATOR: your-github-login
|
|
120
120
|
# Seconds a push (`synchronize`) waits before any model call. A newer push cancels this run
|
|
121
121
|
# while it sleeps (the `review` job's concurrency group), so it spends nothing. Only pushes
|
|
122
122
|
# wait; `opened` and `ready_for_review` start at once. `0` disables the wait. The wait counts
|
|
123
123
|
# toward the job's 30 minute limit.
|
|
124
|
-
|
|
124
|
+
WACHIMAN_PUSH_DEBOUNCE_SECONDS: 180
|
|
125
125
|
# Trial. PR Confidence: after a full review of a pull request, one more small model call grades
|
|
126
126
|
# whether the diff does what the title and body say, and writes it into the pull request
|
|
127
127
|
# description. Each push first resets it to "cannot say", and a push after the first review is
|
|
128
128
|
# reviewed incrementally, which is not graded, so it stays "cannot say" until a review of the whole
|
|
129
129
|
# pull request runs. Not an approval or a check. `1` turns it on. See docs/pr-confidence.md
|
|
130
|
-
|
|
130
|
+
WACHIMAN_CONFIDENCE: 0
|
|
131
131
|
|
|
132
132
|
jobs:
|
|
133
133
|
review:
|
|
@@ -144,7 +144,7 @@ jobs:
|
|
|
144
144
|
runs-on: ubuntu-latest
|
|
145
145
|
timeout-minutes: 30 # batches run one after another
|
|
146
146
|
concurrency:
|
|
147
|
-
group:
|
|
147
|
+
group: wachiman-review-${{ github.event.pull_request.number }}
|
|
148
148
|
cancel-in-progress: true
|
|
149
149
|
permissions:
|
|
150
150
|
contents: read
|
|
@@ -164,7 +164,7 @@ jobs:
|
|
|
164
164
|
|
|
165
165
|
# PR Confidence: before the push wait and with no model call, the description block becomes
|
|
166
166
|
# "cannot say" for the commit under review, so a run that a newer push cancels during the wait
|
|
167
|
-
# leaves no grade of an older commit. The command does nothing when
|
|
167
|
+
# leaves no grade of an older commit. The command does nothing when WACHIMAN_CONFIDENCE is
|
|
168
168
|
# off, so no condition on it is needed here. Best-effort: it never stops the review.
|
|
169
169
|
- name: Reset PR Confidence for this commit
|
|
170
170
|
if: github.event.action == 'synchronize'
|
|
@@ -173,15 +173,15 @@ jobs:
|
|
|
173
173
|
GH_TOKEN: ${{ github.token }}
|
|
174
174
|
PR: ${{ github.event.pull_request.number }}
|
|
175
175
|
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
176
|
-
run: bun --no-env-file --config=scripts/
|
|
176
|
+
run: bun --no-env-file --config=scripts/wachiman/bunfig.toml scripts/wachiman/cli.ts reset-confidence "$PR" --commit "$HEAD_SHA"
|
|
177
177
|
|
|
178
178
|
# Before any model call: a run cancelled here has spent nothing.
|
|
179
179
|
- name: Wait for further pushes
|
|
180
180
|
if: github.event.action == 'synchronize'
|
|
181
181
|
run: |
|
|
182
|
-
seconds="${
|
|
182
|
+
seconds="${WACHIMAN_PUSH_DEBOUNCE_SECONDS//[[:space:]]/}"
|
|
183
183
|
if ! [[ "$seconds" =~ ^[0-9]+$ ]]; then
|
|
184
|
-
echo "::warning title=
|
|
184
|
+
echo "::warning title=WACHIMAN_PUSH_DEBOUNCE_SECONDS ignored::'$WACHIMAN_PUSH_DEBOUNCE_SECONDS' is not a whole number of seconds; not waiting."
|
|
185
185
|
exit 0
|
|
186
186
|
fi
|
|
187
187
|
if [ "$seconds" -gt 0 ]; then
|
|
@@ -195,7 +195,7 @@ jobs:
|
|
|
195
195
|
# Optional: pin the binary's SHA-256 yourself. Empty means the publisher's manifest.
|
|
196
196
|
CLAUDE_CODE_SHA256: ""
|
|
197
197
|
run: |
|
|
198
|
-
bash scripts/
|
|
198
|
+
bash scripts/wachiman/install-claude-code.sh
|
|
199
199
|
echo "$CLAUDE_INSTALL_DIR" >> "$GITHUB_PATH"
|
|
200
200
|
|
|
201
201
|
- name: Review the pull request
|
|
@@ -206,15 +206,15 @@ jobs:
|
|
|
206
206
|
GH_TOKEN: ${{ github.token }}
|
|
207
207
|
PR: ${{ github.event.pull_request.number }}
|
|
208
208
|
# `opened`, `ready_for_review` or `synchronize`: each counts against the automatic ceiling.
|
|
209
|
-
|
|
209
|
+
WACHIMAN_TRIGGER: ${{ github.event.action }}
|
|
210
210
|
# `--config=<path>` needs the equals sign: `-c <path>` did not replace the head's config
|
|
211
211
|
# in Bun 1.3.4. `--no-env-file` keeps the head's `.env` out of this process.
|
|
212
|
-
run: bun --no-env-file --config=scripts/
|
|
212
|
+
run: bun --no-env-file --config=scripts/wachiman/bunfig.toml scripts/wachiman/cli.ts review "$PR" --repo-dir .
|
|
213
213
|
|
|
214
214
|
threads:
|
|
215
215
|
name: Wachiman thread replies
|
|
216
216
|
# EDIT THIS: replace 'your-github-login' below with the operator's login, and keep it equal to
|
|
217
|
-
#
|
|
217
|
+
# WACHIMAN_OPERATOR above. A comment in the review panel starts the job when the operator wrote
|
|
218
218
|
# it and it is a reply, or when it starts with the mention and the operator or (only when
|
|
219
219
|
# `askers` is `write`, see above) an OWNER, MEMBER or COLLABORATOR wrote it, on a head in this
|
|
220
220
|
# repository. The collaborator case is a cheap pre-filter: the engine checks the login again,
|
|
@@ -225,7 +225,6 @@ jobs:
|
|
|
225
225
|
github.event.comment.user.type != 'Bot' &&
|
|
226
226
|
((github.event.comment.user.login == 'your-github-login' && github.event.comment.in_reply_to_id) ||
|
|
227
227
|
((startsWith(github.event.comment.body, '/wachi') ||
|
|
228
|
-
startsWith(github.event.comment.body, '@agent-review') ||
|
|
229
228
|
startsWith(github.event.comment.body, '@claude')) &&
|
|
230
229
|
(github.event.comment.user.login == 'your-github-login' ||
|
|
231
230
|
('operator' == 'write' &&
|
|
@@ -237,7 +236,7 @@ jobs:
|
|
|
237
236
|
# seconds before. GitHub keeps one pending run per group, and a run handles every pending
|
|
238
237
|
# thread, so a dropped pending run loses nothing.
|
|
239
238
|
concurrency:
|
|
240
|
-
group:
|
|
239
|
+
group: wachiman-review-threads-${{ github.event.pull_request.number }}
|
|
241
240
|
cancel-in-progress: false
|
|
242
241
|
permissions:
|
|
243
242
|
contents: read
|
|
@@ -260,7 +259,7 @@ jobs:
|
|
|
260
259
|
# Optional: pin the binary's SHA-256 yourself. Empty means the publisher's manifest.
|
|
261
260
|
CLAUDE_CODE_SHA256: ""
|
|
262
261
|
run: |
|
|
263
|
-
bash scripts/
|
|
262
|
+
bash scripts/wachiman/install-claude-code.sh
|
|
264
263
|
echo "$CLAUDE_INSTALL_DIR" >> "$GITHUB_PATH"
|
|
265
264
|
|
|
266
265
|
- name: Answer the pending threads
|
|
@@ -270,24 +269,24 @@ jobs:
|
|
|
270
269
|
# CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
271
270
|
GH_TOKEN: ${{ github.token }}
|
|
272
271
|
PR: ${{ github.event.pull_request.number }}
|
|
273
|
-
|
|
272
|
+
WACHIMAN_COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
|
|
274
273
|
# The reply's text and place, for a question in a thread (environment only, never interpolated).
|
|
275
274
|
REQUEST: ${{ github.event.comment.body }}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
run: bun --no-env-file --config=scripts/
|
|
275
|
+
WACHIMAN_COMMENT_ID: ${{ github.event.comment.id }}
|
|
276
|
+
WACHIMAN_COMMENT_IN_REPLY_TO: ${{ github.event.comment.in_reply_to_id }}
|
|
277
|
+
WACHIMAN_COMMENT_PATH: ${{ github.event.comment.path }}
|
|
278
|
+
WACHIMAN_COMMENT_LINE: ${{ github.event.comment.line || github.event.comment.original_line }}
|
|
279
|
+
run: bun --no-env-file --config=scripts/wachiman/bunfig.toml scripts/wachiman/cli.ts threads "$PR" --repo-dir .
|
|
281
280
|
|
|
282
281
|
on-demand:
|
|
283
282
|
name: Wachiman on demand
|
|
284
283
|
# EDIT THIS: replace 'your-github-login' below with the operator's login, and keep it equal
|
|
285
|
-
# to
|
|
284
|
+
# to WACHIMAN_OPERATOR above (a job `if:` cannot read `env`). Matching by login works
|
|
286
285
|
# for user-owned and organisation-owned repositories alike (`author_association` is `OWNER`
|
|
287
|
-
# in the first and `MEMBER` in the second). `@
|
|
286
|
+
# in the first and `MEMBER` in the second). `@claude` is accepted as an alias
|
|
288
287
|
# while installed copies migrate. A comment that starts with the mention from an OWNER, MEMBER
|
|
289
288
|
# or COLLABORATOR also starts the job, but only when `askers` is `write` (the `'operator' == 'write'`
|
|
290
|
-
# literal in the threads job, changed with
|
|
289
|
+
# literal in the threads job, changed with WACHIMAN_ASKERS at the top), as a pre-filter only:
|
|
291
290
|
# the engine refuses it unless GitHub confirms write access.
|
|
292
291
|
if: |
|
|
293
292
|
github.event_name == 'issue_comment' &&
|
|
@@ -297,19 +296,17 @@ jobs:
|
|
|
297
296
|
'operator' == 'write' &&
|
|
298
297
|
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) &&
|
|
299
298
|
(startsWith(github.event.comment.body, '/wachi') ||
|
|
300
|
-
startsWith(github.event.comment.body, '@agent-review') ||
|
|
301
299
|
startsWith(github.event.comment.body, '@claude')))) &&
|
|
302
300
|
(contains(github.event.comment.body, '/wachi') ||
|
|
303
|
-
contains(github.event.comment.body, '@agent-review') ||
|
|
304
301
|
contains(github.event.comment.body, '@claude'))
|
|
305
302
|
runs-on: ubuntu-latest
|
|
306
303
|
timeout-minutes: 30 # batches run one after another
|
|
307
304
|
# The operator's runs keep their group and cancel one another. A collaborator's question has its
|
|
308
305
|
# own group that never cancels, so it cannot cancel the operator's review of the pull request.
|
|
309
306
|
# The login is a literal here because a concurrency block cannot read env: keep it equal to
|
|
310
|
-
#
|
|
307
|
+
# WACHIMAN_OPERATOR.
|
|
311
308
|
concurrency:
|
|
312
|
-
group:
|
|
309
|
+
group: wachiman-review-on-demand-${{ github.event.issue.number }}${{ github.event.comment.user.login != 'your-github-login' && '-ask' || '' }}
|
|
313
310
|
cancel-in-progress: ${{ github.event.comment.user.login == 'your-github-login' }}
|
|
314
311
|
permissions:
|
|
315
312
|
contents: read
|
|
@@ -342,7 +339,7 @@ jobs:
|
|
|
342
339
|
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
|
343
340
|
with:
|
|
344
341
|
path: .ci-main
|
|
345
|
-
sparse-checkout: scripts/
|
|
342
|
+
sparse-checkout: scripts/wachiman
|
|
346
343
|
fetch-depth: 1
|
|
347
344
|
|
|
348
345
|
- name: Setup Bun
|
|
@@ -356,7 +353,7 @@ jobs:
|
|
|
356
353
|
# Optional: pin the binary's SHA-256 yourself. Empty means the publisher's manifest.
|
|
357
354
|
CLAUDE_CODE_SHA256: ""
|
|
358
355
|
run: |
|
|
359
|
-
bash .ci-main/scripts/
|
|
356
|
+
bash .ci-main/scripts/wachiman/install-claude-code.sh
|
|
360
357
|
echo "$CLAUDE_INSTALL_DIR" >> "$GITHUB_PATH"
|
|
361
358
|
|
|
362
359
|
# The comment reaches the CLI through the environment, never interpolated
|
|
@@ -369,5 +366,5 @@ jobs:
|
|
|
369
366
|
GH_TOKEN: ${{ github.token }}
|
|
370
367
|
PR: ${{ github.event.issue.number }}
|
|
371
368
|
REQUEST: ${{ github.event.comment.body }}
|
|
372
|
-
|
|
373
|
-
run: bun --no-env-file --config=.ci-main/scripts/
|
|
369
|
+
WACHIMAN_COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
|
|
370
|
+
run: bun --no-env-file --config=.ci-main/scripts/wachiman/bunfig.toml .ci-main/scripts/wachiman/cli.ts comment "$PR" --repo-dir .
|
|
@@ -28,6 +28,11 @@ on:
|
|
|
28
28
|
permissions: { contents: read, pull-requests: write, issues: read }
|
|
29
29
|
jobs:
|
|
30
30
|
review:
|
|
31
|
+
# Optional, to enroll in a spend ledger that limits spend per day and per week across repositories
|
|
32
|
+
# (docs/costs.md): change `review.yml` below to `review-platform.yml`, add `id-token: write` to the
|
|
33
|
+
# `permissions:` line at the top, and add `ledger_url` (and optionally `daily_budget_usd`) to `with:`
|
|
34
|
+
# next to `operator`. `v1.5.0` is a placeholder: `review-platform.yml` exists only from the first
|
|
35
|
+
# release that contains it, so pin that release or later. Leave all of this out and nothing changes.
|
|
31
36
|
uses: niway-dev/wachiman/.github/workflows/review.yml@v1.5.0
|
|
32
37
|
with:
|
|
33
38
|
operator: EDIT-THIS-github-login
|